August 2, 2008

Starting Windows App from Web application with parameters!

Filed under: Tips and Tricks — @ 2:51 am

There will be times you need to invoke windows app from a web application. Not only you need to call the windows application you may need to pass parameters to the windows application.

Here is how went about to solve the problem. I created the windows application as a click once application and publised it. One important part you have to remember is to enable the windows application to accept parameters. This option is under publish tab under project properties. While you are in publish tab, choose options button and check the check box pretaining to enabling the windows application to accept paramters.

To enable the windows application to get parameters from the web application you have to add the following code segment in the windows application.

if (ApplicationDeployment.IsNetworkDeployed)
string queryString = ApplicationDeployment.CurrentDeployment.ActivationUri.Query

It is important that we add initial ‘if’ statement to make sure we try to get the parameter only if the application is in network installed. If you are testing the appliation locally then this part of the code will not work. Also after you get the queryString, you need to split the key value pair to get your required information.

So the bottom line, develop the windows application with above mentioned code snippet in the contructor of the form. Also make application aware of the parameter coming in from web application in the publish options.

Now lets look at the web side. When you deploy the windows application, normally it get deployed with the following url like


now from web site to launch the application, you would call the following url


and add the parameter with following string pattern


Thats it, now when you run the web application, the link will launch the application from the publish folder and the when the application run, the windows application will get the parameters from the web application through activation uri.

** The activation url might return zero or null value if you try to test the code with localhost. You have to test with actual computer name in the web application link.

Ads by

Tags: , , ,

Powered by Qumana

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress