是什么原因导致在WPF应用程序的InvalidDeploymentException? [英] What causes an InvalidDeploymentException in a WPF application?

查看:2295
本文介绍了是什么原因导致在WPF应用程序的InvalidDeploymentException?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个WPF应用程序,当我启动它在调试模式下我看到在输出以下内容:

I developed a WPF application and when I launch it in the debug mode I see the following in the output:

WpfApplication1.vshost.exe(管理   (V2.0.50727)):加载   C:\ WINDOWS \组装\ GAC_MSIL \ System.Deployment \ 2.0.0.0__b03f5f7f11d50a3a \ System.Deployment.dll',   符号加载。第一次机会   异常类型   System.Deployment.Application.InvalidDeploymentException   发生在System.Deployment.dll   其他信息:应用程序   身份未设置。

'WpfApplication1.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\System.Deployment\2.0.0.0__b03f5f7f11d50a3a\System.Deployment.dll', Symbols loaded. A first chance exception of type 'System.Deployment.Application.InvalidDeploymentException' occurred in System.Deployment.dll Additional information: Application identity is not set.

如果我使用来自在另一个WPF应用程序本申请的控制,有在输出7这样的消息。然而,应用程序工作正常。

If I use a control from this application in another WPF application, there are 7 such messages in the output. Nevertheless, the application works fine.

你能解释为什么这些抛出的异常的原因是什么?我发现,该方法 ApplicationDeployment.get_CurrentDeployment 提出了他们。在MSDN上记着,当此异常出现您试图调用从非ClickOnce应用程序这个静态的财产。我不明白是什么意思。

Could you explain the reason why these exceptions thrown? I found that the method ApplicationDeployment.get_CurrentDeployment raises them. In the MSDN it is written that this exception arises when "You attempted to call this static property from a non-ClickOnce application." I can’t understand what it means.

我发现类似的帖子<一href="http://stackoverflow.com/questions/1894837/invaliddeploymentexception-application-identity-is-not-set">InvalidDeploymentException - 应用程序标识没有设置但没有回答这个问题。

I found similar post InvalidDeploymentException - Application identity is not set but there is no answer to this question.

推荐答案

这是一个第一次机会异常,这意味着调试器简单地通知您一个异常被抛出,而不是一个是未处理的。

This is a "first chance exception", which means the debugger is simply notifying you that an exception was thrown, rather than that one was unhandled.

.NET框架的抛出和捕获该异常内部,调试器会告诉你,它发生在约code。在 System.Deployment.dll 。唯一的例外时引发试图访问用户/网络信息,但是当它发生在底层code为捕捉异常,并自动恢复执行。还有,你可以做什么,它是相对无害的。

The .NET Framework is throwing and catching that exception internally—the debugger tells you that it occurs in some code in System.Deployment.dll. The exception is raised when an attempt is made to access user/network information, but the underlying code is catching the exception when it occurs and automatically resuming execution. There's nothing you can do about it, and it's relatively harmless.

您最有可能试图检索应用程序数据路径为当前用户,在这种情况下,框架需要确定您的应用程序是一个正常的应用程序,或者为了返回正确路径的ClickOnce应用程序。如果你是一个的ClickOnce应用程序,只是返回正确的数据。否则,抛出一个异常,这是陷入了框架和假设,即您的应用程序的没有的一个的ClickOnce应用程序,使标准用户路径返回,而不是。

You are most likely attempting to retrieve the AppData path for the current user, in which case the Framework needs to determine if your application is a normal app or a ClickOnce app in order to return the correct path. If you are a ClickOnce app, the correct data is simply returned. Otherwise, an exception is thrown, which is caught by the Framework and the assumption is made that your application is not a ClickOnce app, causing the standard user path to be returned instead.

有一个数字的引发和处理的应用程序运行时异常。有没有害处,除非他们是无法处理的。如果这真的是你的错误,你可以自定义哪些调试器会通知你的例外。例如:

There are a number of exceptions that are thrown and handled while an application is running. There's no harm unless they're unhandled. If this really bugs you, you can customize the exceptions about which the debugger informs you. For example:

  1. 从调试菜单,打开例外窗口。
  2. 展开通用语言运行时例外 - >System.Deployment.Application
  3. 取消勾选​​框旁边的System.Deployment.Application.InvalidDeploymentException。

这篇关于是什么原因导致在WPF应用程序的InvalidDeploymentException?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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