ClickOnce appref.ms argument

时光毁灭记忆、已成空白 提交于 2019-12-04 09:07:46
Joel Cochran

I was able to get this to work by referencing the app as "%userprofile%\Desktop\Your Shortcut Name Here.appref-ms"

Then, to pass the parms, pass them as a single, no space entity like so: arg1,arg2,arg3

The whole thing looks like this on the command line:

"%userprofile%\Desktop\Your Shortcut Name Here.appref-ms" arg1,arg2,arg3

Then in your code, use

AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]

to retrieve the args.

I just blogged about this yesterday: http://www.developingfor.net/net/processing-command-line-arguments-in-an-offline-clickonce-application.html

You can pass arguments to an offline ClickOnce application. I would just set up a shortcut that points to the ClickOnce shortcut and adds arguments at the end. Click here to check out the article on how to pass and process arguments for an offline ClickOnce app.

No, you can't pass arguments from the Start Menu shortcut. If you find a way, let me know because I've been trying to do it for a long time :).

Here's how I address the problem in my situation...

If the ActivationUri property is not null, the application was launched from a browser and passed arguments via the query string (just like you described).

If the ActivationUri is null, the application was launched from the start menu. In these cases, I get the arguments from a config file deployed with the application.

What type of information is being passed with your argument? That would be useful in order to determine how you should store your arguments (app.config, application settings, user settings, isolated storage, etc.)

Side Note
I thought I was on to something by making my application "single instance" and trying to handle the StartupNextInstance application event, but no luck. You can only get traditional command line parameters that way, not the ClickOnce query string parameters.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!