Application identity not set Exception

我怕爱的太早我们不能终老 提交于 2019-12-20 16:20:57

问题


I have just converted a project to VS2010 and I now starting to see Exceptions in my software in IntelliTrace.

One such Exception is 'Application identity is not set', this occurs whenever my software see's something like

string m_AppPath = Application.UserAppDataPath;

This isn't a problem as the AppDataPath returns correctly, I'm just wondering why this happens.

The code is in the Main function of Program.cs (if that makes a difference), once out of the Program.cs file and into MainWindow.cs the code works.

My main issue is that I setup Logging prior to the application starting. Any help appreciated as searching the web doesn't really help.

Paul


回答1:


If the problem is occuring in debugging you can first check if the debugger is attached before accessing any application settings:

If System.Diagnostics.Debugger.IsAttached then
       Me.Text = "Debug Mode"
Else 
       Me.Text = "Version " & My.Application.Deployment.CurrentVersion.ToString
End If



回答2:


I found that this problem exists only if you untick "Just My Code" under debug options.




回答3:


If this is a ClickOnce application being debugged, another option is to check the System.Deployment.Application.ApplicationDeployment.IsNetworkDeployed setting.



来源:https://stackoverflow.com/questions/3307798/application-identity-not-set-exception

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