How does one pass command line argument to a ClickOnce application?

跟風遠走 提交于 2019-11-27 01:39:08

问题


I have a Clickonce application that is launched from the start menu (local). I would like to be able to specify a parameter so that the application can load certain data. The application lives on a fileshare and will be launched using the URL only once (like described here on MSDN). This implies that the method describe in this link will not work; users will be launching the application using an .appref-ms shortcut in the Start Menu.

I haven't been able to find a solution. Is it possible to somehow pass a parameter into the click once application? If so, how? If not, what are some alternatives?


回答1:


Since you get to the deployment manifest via a Url, you can pass all of that information via the query string (e.g. http://clickonce.example.com/shell.application?p1=this&p2=that)

I was going to type out the steps, then googled and found this blog that basically lists out all the steps. I've done something similar in one instance with no issues. The only slightly difficult thing is that you have to re-mage after setting things up, but if you got it to deploy in the first place, you already know how to set things up.

Good luck!




回答2:


All of the answers here only apply to Online ClickOnce applications. This MSDN Forum post and this blog post discuss some ways to do it for Offline ClickOnce applications.




回答3:


Perhaps you could pass a parameter on the URL the first time, and have the app take notice of that, and write the parameters to a config file, or environment variables or somesuch.

On subsequent runs, load from the config file




回答4:


You pass the parameters as a query string and use HttpUtility.ParseQueryString, as discussed in this MSDN article.



来源:https://stackoverflow.com/questions/429351/how-does-one-pass-command-line-argument-to-a-clickonce-application

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