What causes an InvalidDeploymentException in a WPF application? What causes an InvalidDeploymentException in a WPF application? wpf wpf

What causes an InvalidDeploymentException in a WPF application?


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