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

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

问题描述

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


'WpfApplication1。 vshost.exe'(Managed
(v2.0.50727)):加载
'C:\WINDOWS\assembly\GAC_MSIL\System.Deployment\2.0.0.0__b03f5f7f11d50a3a\System.Deployment .dll',
加载符号。第一个机会
异常类型
'System.Deployment.Application.InvalidDeploymentException'
发生在System.Deployment.dll
附加信息:应用程序
标识未设置


如果我在另一个WPF应用程序中使用此应用程序的控件,则输出中有7个此类消息。然而,应用程序工作正常。



你能解释为什么抛出这些异常的原因吗?我发现方法 ApplicationDeployment.get_CurrentDeployment 引发它们。在MSDN中,写道:当您尝试从非ClickOnce应用程序调用此静态属性时,会出现此异常。我无法理解它的含义。



我发现类似的帖子 InvalidDeploymentException - 应用程序身份未设置,但没有回答这个问题。

解决方案

这是一个第一次机会异常,这意味着调试器只是通知你抛出异常,而不是那个没有被处理。



.NET Framework在内部抛出异常的异常,调试器告诉你,它发生在系统中的一些代码中.Deployment.dll 。当尝试访问用户/网络信息时,引发异常,但是底层代码在发生异常并且自动恢复执行时捕获异常。你没有什么可以做的,它是相对无害的。



你最有可能尝试检索当前用户的AppData路径,在这种情况下框架需要确定您的应用程序是正常的应用程序还是ClickOnce应用程序,以返回正确的路径。如果您是ClickOnce应用程序,则只返回正确的数据。否则,抛出异常,这被框架捕获,并假设您的应用程序不是一个ClickOnce应用程序,导致返回标准用户路径。



在应用程序运行时,抛出并处理了许多异常。没有伤害,除非他们没有处理。如果这真的很错误,您可以自定义调试器通知您的异常。例如:


  1. 从调试菜单中打开例外窗口。

  2. 展开公共语言运行时异常 - >System.Deployment.Application。

  3. 取消选中System.Deployment.Application.InvalidDeploymentException旁边的框。


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

'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.

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.

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.

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.

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.

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. Open the Exceptions window from the Debug menu.
  2. Expand "Common Language Runtime Exceptions" -> "System.Deployment.Application".
  3. Uncheck the box next to "System.Deployment.Application.InvalidDeploymentException".

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

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