ClickOnce Help

P

Peter Carlson

Not sure if this is the right NG, if not please point me in the right
direction.

We are developing a clickonce installer for our program Here are my
basic questions:

1. How can I really debug this? Simply pressing F5 in VS2005, doesn't
really provide the same environment...for example no Http query string

2. After publishing to the hard drive if I open publish.htm in IE and
then click on run, nothing happens - it's like it never opens the app.
If I use IE and go directly to the .application file it never opens.
Only if I publish to a website, this makes minor debugging a pain as I
have to repost for every little code change,

3. Finally, the last question for now. Our app needs to read the query
string. in vs2005 I have set it as a full trust application. When i
run it it generates this exception:
System.NullReferenceException ... Form1.GetQueryStringParameters()

and then the sQuery variable is empty as shown in the MessageBox. I
have changed publish.htm to be:
directLink = "clickonceinstaller.application?server=foo&test=peter";

Code from form1.cs is:
NameValueCollection aParams;
string sQuery;

private void Form1_Load(object sender, EventArgs e)
{
aParams = GetQueryStringParameters();
MessageBox.Show(sQuery);
if (aParams.Count == 0) { this.Close(); return; }
}

private NameValueCollection GetQueryStringParameters()
{
NameValueCollection nameValueTable = new NameValueCollection();
if (ApplicationDeployment.IsNetworkDeployed)
{
try
{
string queryString =
ApplicationDeployment.CurrentDeployment.ActivationUri.Query;
sQuery = queryString;
nameValueTable =
System.Web.HttpUtility.ParseQueryString(queryString);
}
catch (Exception exception)
{ MessageBox.Show(exception.ToString()); }
}
return (nameValueTable);
}


Thanks to all!
Peter
 
M

Marc Gravell

1.  How can I really debug this? [snip] for example no Http query string
3.  [snip] Our app needs to read the query string

Note you need to ensure that this is enabled (i.e. the app allows QS
args: Project Properties -> Publish -> Options -> Allow URL parameters
to be passed to application).
Once this is done, I use the following, which allows me to treat
command line args and QS args the same - and then I can debug by
setting the debug command line arguments:

public static string[] GetStartupArguments() {
List<string> allOptions = new List<string>();
try // command line
{
string[] options =
System.Environment.GetCommandLineArgs();
if (options != null) { // strip the first (the exe
name)
int length = options.Length;
for (int i = 1; i < length; i++)
allOptions.Add(options);
}
} catch { }
try // query string
{
if
(System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
{
string[] options =
AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData;
if (options != null && options.Length > 0) {
foreach (string queryItem in new
Uri(options[0]).Query.TrimStart('?').Split('&')) {

allOptions.Add(System.Web.HttpUtility.UrlDecode(queryItem));
}
}
}
} catch { }

return allOptions.ToArray();
}
 
P

Peter Carlson

Marc,

The Properties page is what I was missing. Thanks
Peter

Marc said:
1. How can I really debug this? [snip] for example no Http query string
3. [snip] Our app needs to read the query string

Note you need to ensure that this is enabled (i.e. the app allows QS
args: Project Properties -> Publish -> Options -> Allow URL parameters
to be passed to application).
Once this is done, I use the following, which allows me to treat
command line args and QS args the same - and then I can debug by
setting the debug command line arguments:

public static string[] GetStartupArguments() {
List<string> allOptions = new List<string>();
try // command line
{
string[] options =
System.Environment.GetCommandLineArgs();
if (options != null) { // strip the first (the exe
name)
int length = options.Length;
for (int i = 1; i < length; i++)
allOptions.Add(options);
}
} catch { }
try // query string
{
if
(System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed)
{
string[] options =
AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData;
if (options != null && options.Length > 0) {
foreach (string queryItem in new
Uri(options[0]).Query.TrimStart('?').Split('&')) {

allOptions.Add(System.Web.HttpUtility.UrlDecode(queryItem));
}
}
}
} catch { }

return allOptions.ToArray();
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top