Trial Applications For Windows Phone 7

18. May 2010

windows-phone-7 I just started teaching myself how to develop applications for Windows Phone 7 in anticipation for the Holiday 2010 release.  Being a completely new to  windows mobile app development, one question I had was whether or not applications can be made available in the WP7 Marketplace on a trial basis; and if so what do I need to consider when coding my application concerning the trial version of the application?

It turns out that WP7 apps can be made available on a trial basis. I haven’t yet registered as a developer in the marketplace, but I did find out that during the application submission process, you can indicate that you want to make your application available on a trial basis. The WP7 Marketplace apparently handles the whole trial try-before-you-buy scenario for you.  That answers my first question.

As far as coding WP7 applications to include a trial mode/version there is some work to do, although it’s relatively simple work.  Microsoft has provided us with a class just for this purpose:

Microsoft.Phone.License.LicenseInfo

The LicenseInfo class has one method in particular we’ll need to develop the trial mode for our app – the IsTrial() method. The method does exactly what it indicates  - it returns a Boolean value indicating with the application is running in a trial status.

While developing using the LicenseInfo.IsTrial() method, it will always return True. The method will work correctly only after your application has been downloaded and ran through the WP7 Marketplace.  During development you will need to simulate trial/non-trial status with your own Boolean variable or some other simulation.

Anyway, just a quick run-down on a couple of things I learned about developing trial applications for Windows Phone 7! Hopefully this  post will help other developers with the same questions I had.

Enjoy!

Windows Phone 7

 Simple Trick To Publish ANY File Via ClickOnce

5. May 2010

I recently needed to deploy a WPF application with ClickOnce and have the deployment include an ActiveX DLL.  I couldn’t simply add a reference to the DLL in my solution. When I tried I Visual Studio said:

Please make sure that the file is accessible, and that it is a valid assembly or COM component.

Since I couldn’t add it as a reference – it wouldn’t show up in my “Application Files” list (Publish tab of project properties). If it isn’t in the Application Files list then we are unable to include it in the ClickOnce publish.

To get around this issue there is a simple trick you can do to push your ActiveX DLL (or any file type ) into a ClickOnce publish. Here are the steps:

 

  1. Rename your file to include a .txt extension. It should look something like “myassembly.dll.txt” or [name].[extension].txt’
  2. Add the renamed file to your solution.
  3. In Solution Explorer right-click the file, select properties, and change the Build Action to “Content”
  4. Now go back to Application Files on the Publish tab of the project properties. You should see your file in the list. If they aren’t already set – change the drop downs so that the values are as follows:

 

  • Publish Status – Include (Auto)
  • Download Group - (Required)
  • Hash - (Include)

 

After those step are complete, you have a small amount of coding to do. We’ll need to rename your file at runtime in order for the file to be usable. To do that we’ll need a bit of code from my last post.

 

if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed) 
{
if (System.Deployment.Application.ApplicationDeployment.CurrentDeployment.IsFirstRun)
{
//sneak the dll into the deployment by renaming it
if (File.Exists("myfile.dll.txt") && !File.Exists("myfile.dll"))
{
//rename to dll so it is accessible
File.Copy("myfile.dll.txt", "myfile.dll");
}
}
}

 

The code above basically checks to see if it is a ClickOnce deployment and if it is the first time the application has been ran on the current machine, and if so, renames the .txt file you publish with it’s real name so it can now be used as originally intended.

Using the method outlined in the post, you should be able to easily publish any file type with your ClickOnce deployed application.

Enjoy!

.NET, WPF ,

 Perform Custom Action - WPF ClickOnce Deployment

4. May 2010

 

If you’d like your WPF application deployed via ClickOnce to execute a custom action the first time the application is run you can use the following code:

 

if (System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
{
      if (System.Deployment.Application.ApplicationDeployment.CurrentDeployment.IsFirstRun)
      {
                 // do some initialization here
       }
}

 

IsNetworkDeployed is a Boolean value indicating whether or not the application has been deployed via ClickOnce. IsFirstRun indicates whether this is the first time the application has been ran on the current machine. Be sure to add a reference to System.Deployment.

Enjoy!

.NET, WPF ,