473,382 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Clickonce deployment and args

Hi!

I have an application as takes 1 argument.
When i start the application from the command line it works, but after clickonce
deployment the deployed my.application does not takes arguments.
The assembly is deployed using an unc path. How do pass an argument to the
application?

The code:

static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new Forms.MainForm(args));
}

Regards
Anders Elmén
May 2 '06 #1
6 8541
Startup the MageUi program; there's an option on the deployment
manefist that allows you to specify arguments via the URL.

HTH
andy

May 2 '06 #2
Hello Andy,

I saw that one. But how do i start the application and pass the arguments?

\\Myserver\MyApp\my.application myarg does not work.

I know it's an UNC path, but if there is some way to do it

Do i have to share the folder using webshare?

Regards,
Anders Elmén
Startup the MageUi program; there's an option on the deployment
manefist that allows you to specify arguments via the URL.

HTH
andy

May 2 '06 #3
Sorry, thought URL for UNC. Unfortunatly I don't know the answer to
that.. I'd think that what you tried would work. If you use a URL,
does it then work?

May 2 '06 #4
Hello Andy,

Thanks for keepning this thread alive :)

In MDSN Documentation there is an sample of how to obtain query string information
from a ClickOnce application.
In the sampe they use http://servername/WindowsApp1.manifest?username=joeuser
as query string and the following method to parse the string.

private Dictionary<string, string> GetQueryStringParameters()
{
Dictionary<string, string> nameValueTable = new Dictionary<string, string>();

if (ApplicationDeployment.IsNetworkDeployed)
{
string url = AppDomain.CurrentDomain.SetupInformation.Activatio nArguments.ActivationData[0];
string queryString = (new Uri(url)).Query;
string[] nameValuePairs = queryString.Split('&');
foreach (string pair in nameValuePairs)
{
string[] vars = pair.Split('=');
if (!nameValueTable.ContainsKey(vars[0]))
{
nameValueTable.Add(vars[0], vars[1]);
}
}
}

return (nameValueTable);
}

If i translate this into my own application

http://andelm/Ericsson/BankGuar/Bank...est?Company=T3

When i hit the return key a dialog box appears with the open or save dialog.
The application is not executed. When opening I get the manifest xml file
opened in VS2003.

Any idéa?

Regards,

Anders Elmén

Sorry, thought URL for UNC. Unfortunatly I don't know the answer to
that.. I'd think that what you tried would work. If you use a URL,
does it then work?

May 3 '06 #5
The solution.

1. if you want your application to receive args, publish your application
with http
2. Add this to your code in program.cs:

using System.Deployment.Application;

static void Main(string[] args)
{
string lParameter = "CompanyCode";
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
string[] AppArgs = new string[] { "" };

if (ApplicationDeployment.IsNetworkDeployed)
{
Dictionary<string, string> param = GetQueryStringParameters();
if (!param.TryGetValue(lParameter, out AppArgs[0]))
{
MessageBox.Show(string.Format("Missing parameter {0}",lParameter));
return;
}
}
else
{
AppArgs = args;
}
Application.Run(new Forms.MainForm(AppArgs));
}

static Dictionary<string, string> GetQueryStringParameters()
{
Dictionary<string, string> nameValueTable = new Dictionary<string,
string>();

if (ApplicationDeployment.IsNetworkDeployed)
{
string url = AppDomain.CurrentDomain.SetupInformation.Activatio nArguments.ActivationData[0];
string queryString = (new Uri(url)).Query;
string[] nameValuePairs = queryString.Split('&');
foreach (string pair in nameValuePairs)
{
string[] vars = pair.Split('=');
if (!nameValueTable.ContainsKey(vars[0]))
{
nameValueTable.Add(vars[0], vars[1]);
}
}
}

return (nameValueTable);
}
}

3. Publish your application and start it with http://server/my.application?Dummy=na&CompanyCode=01

The reason why i have to use the dummy parameter is that the GetQueryStringParameters()
method only splits the & sign.
Feel free to add a split function on the ? sign.

Regards,
Anders Elmén
Hello Andy,

Thanks for keepning this thread alive :)

In MDSN Documentation there is an sample of how to obtain query string
information
from a ClickOnce application.
In the sampe they use
http://servername/WindowsApp1.manifest?username=joeuser
as query string and the following method to parse the string.
private Dictionary<string, string> GetQueryStringParameters()
{
Dictionary<string, string> nameValueTable = new Dictionary<string,
string>();
if (ApplicationDeployment.IsNetworkDeployed)
{
string url =
AppDomain.CurrentDomain.SetupInformation.Activatio nArguments.Activatio
nData[0];
string queryString = (new Uri(url)).Query;
string[] nameValuePairs = queryString.Split('&');
foreach (string pair in nameValuePairs)
{
string[] vars = pair.Split('=');
if (!nameValueTable.ContainsKey(vars[0]))
{
nameValueTable.Add(vars[0], vars[1]);
}
}
}
return (nameValueTable);
}
If i translate this into my own application

http://andelm/Ericsson/BankGuar/Bank...ar.exe.manifes
t?Company=T3

When i hit the return key a dialog box appears with the open or save
dialog. The application is not executed. When opening I get the
manifest xml file opened in VS2003.

Any idéa?

Regards,

Anders Elmén
Sorry, thought URL for UNC. Unfortunatly I don't know the answer to
that.. I'd think that what you tried would work. If you use a URL,
does it then work?

May 3 '06 #6
I hope that VS2003 is a typo; ClickOnce and that URL method of
parameters is only supported in .net 2.0 and VS2005.

Also, you don't want to link to the manefist, you need to link to the
..application file (aka the Deployment manifest).

HTH.
ANdy

May 3 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mika M | last post by:
Hi! I made ClickOnce deployment for Windows Forms VB 2005 application, and it's working mostly fine. Now I have some question: 1. Is it okay when my application goes into x:\Documents and...
1
by: moondaddy | last post by:
I need to have multiple deployment profiles for a .net 2.0 winforms project. This is my requirement: 1) Re-use same project for multiple ClickOnce deployment profiles. 2) Each profile will...
3
by: Chris Rennert | last post by:
Hey all, we have a project that we would like to use ClickOnce deployment on, and although it all seems straightforward we are having a few issues concerning SQL Server Express and clickonce. We...
0
by: T | last post by:
We were looking at building a Windows Client application using VS 2003 and the Updater Application Block. Since the application might also be written in VS 2005, we have started looking at the...
0
by: Spam Catcher | last post by:
Hi all, I need to build a redistributable application which can be loaded on different servers. I noticed in the ClickOnce deployment screen it asks for a publish location - how do I allow...
2
by: =?Utf-8?B?Sm9obiBC?= | last post by:
A windows forms 2.0 ClickOnce deployment fails when both SSL is enabled and "require client certificate" enabled on the IIS deployment web server. Can anyone assist with how to configure this...
3
by: =?Utf-8?B?U2hlaWxh?= | last post by:
Hi, Is it possible to configure ClickOnce deployment so that it will be installed once somewhere on the machine for all users to access instead of installed under individual user profile folder....
0
by: =?Utf-8?B?TVM=?= | last post by:
Hi, Is there any way in Clickonce deployment from visual studio .net 2.0 to Create a folder on the client machine on application install. I could find any properties in clickonce publish to...
7
by: LukasMalik | last post by:
Hi all, my application (C# WinForm .NET 3.5) is distributed via ClickOnce deployment. Application should check for updates on our company web. Problem comes when any part of application has...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.