Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

ClickOnce Application cannot read parameters that passed to it in the url

$
0
0
I need to pass some parameters to clickonce application i.e

http://localhost/publisher/WindowsFormsApplication1.application?username=joeuser
I created simple winform app and publish it with clickonce. When trying to harvest the parameters from the query string I am getting nothing

I did set the target framework to .Net Framework 3.5 . and set the options to enable Allow URL parameters to be passed to application check box shown here

this is what I was trying to do : 

1st trial:

var args = AppDomain.CurrentDomain.SetupInformation.ActivationArguments;
if (args != null && args.ActivationData != null && args.ActivationData.Length > 0) {
    var url = new Uri(args.ActivationData[0], UriKind.Absolute);
    var parameters = HttpUtility.ParseQueryString(url.Query);
    try { 
         MessageBox.Show(url.Query);  //shows empty
         }catch(Exception ex){
           MessageBox.Show("Got " + ex.Message);
         }
   }
here I didn't got an exception but got empty message box

2nd trial:

NameValueCollection nameValueTable = new NameValueCollection(); if (ApplicationDeployment.IsNetworkDeployed){    try{      string queryString = ApplicationDeployment.CurrentDeployment.ActivationUri.Query;      MessageBox.Show(queryString); //throws exception     

}catch (NullReferenceException ex){             

MessageBox.Show("Got Null");      }   

}

here I got thrown to NullReferenceException 

what am I doing wrong ?

tried the following resources at msdn (http://msdn.microsoft.com/en-us/library/ms172242.aspx) and in this blog (http://riyadsthoughts.blogspot.co.il/2010/03/passing-parameters-to-clickonce.html)

is there any sample project that use this clickonce ability ? 



Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>