应用程序标识没有设置异常 [英] Application identity not set Exception

查看:305
本文介绍了应用程序标识没有设置异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚转换了一个项目,VS2010,我现在开始看到在我的IntelliTrace软件例外。

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;

这是不是一个问题,因为AppDataPath正确返回,我只是想知道为什么会这样。

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

中的代码是在Program.cs中的主要功能(如果有差别),一旦出Program.cs文件,进入MainWindow.cs代码工作

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.

推荐答案

如果该问题在调试可以先检查调试器访问任何应用程序设置前附存在的:

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

这篇关于应用程序标识没有设置异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆