“Store metadata ”CurrentBind“ is not valid” in debug of ClickOnce application

不想你离开。 提交于 2019-12-09 14:54:49

问题


When I try to access "Application.CommonAppDataPath" i get this error message:

System.Deployment: Store metadata "CurrentBind" is not valid

Stack Trace:

at System.Deployment.Application.ComponentStore.GetPropertyString(DefinitionAppId appId, String propName)

This is only in Debug. When running as an actual published clickonce application it works fine.

How can I get rid of this exception when debugging locally?


回答1:


I had a similar issue (like jpierson's comment) with the same exception '"CurrentBind" not valid' on ApplicationDeployment.IsNetworkDeployed. I had unchecked "Options|Debugging|General|Just My Code". After checking it back all worked fine.

NOTE: Some other discussion threads had suggested reinstalling VS2010. I did that but did not help. I don't know if reinstalling was also the fator.




回答2:


I intentionally set VS to break on CLR exceptions. You certainly can mask this exception by only debugging your code but, it is still a valid bug that I'd like an explanation for. MS should be the forerunner on writing solid code.




回答3:


ApplicationDeployment.IsNetworkDeployed (in the System.Deployment.Application namespace) is a boolean property that returns true if the application was launched with ClickOnce.

if (ApplicationDeployment.IsNetworkDeployed)
{
    //CommonAppPath code
}

What are you trying to do with CommonAppDataPath? Depending on what you're trying to accomplish, we could probably come up with something that will work no matter how the app is launched.




回答4:


I had exactly the same problem. Thanks to mkale for pointing me in the right direction.

I had installed the Reflector VS Addin a few days ago, and at some point it asked about changing the Just My Code option. I had completely forgotten about it, and have been messing around with this problem for the last two days!

At the same time I also had a problem with FileLoadException - which was reporting in the Fusion log that "WRN: Comparing the assembly name resulted in the mismatch: Revision Number". Initially I got around that problem by setting the assembly version to 1.1.0.0 instead of as 1.1.*.

However, once having set the Just My Code option, all these problems disappeared.



来源:https://stackoverflow.com/questions/1914531/store-metadata-currentbind-is-not-valid-in-debug-of-clickonce-application

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