XamlParseException after deploying WPF project

旧时模样 提交于 2019-11-27 04:47:08
jjrdk

This is normally caused by not having all dependencies copied to the output. As you say the error message is not very helpful, but I would check that your application has all the necessary dependencies available to resolve the parsed types.

Normally it is enough to set Copy Local to true for referenced assemblies, but I've experienced some cases where references themselves reference assemblies, so it can be necessary to explicitly add those references as well.

Update:

Important addition by @BENN1TH.

If you want to see what an assembly is necessary:

Was getting the same type of issue once i had published and installed my project (was working fine in debug VS2013 Desktop, no errors etc) but used the advice in from http://geekswithblogs.net/lbugnion/archive/2007/03/14/108728.aspx and wham! installed project was working..

try

{
  InitializeComponent();
}
catch ( Exception ex )
{
  // Log error (including InnerExceptions!)
  // Handle exception
}

Cleaning and Rebuilding the solution might help!

I had this problem with a WPF solution in VS2010. The solution contained a simple dll and a test project (set to startup) for testing the dll. My dll was set to x86 and my test project was set to x64. When I changed the test project to x86 the problem was resolved.

If you get this exception in the debugger check the InnerException member of the exception. It might give you a hint about which assembly that is missing.

Was getting the same type of issue once i had published and installed my project (was working fine in debug VS2013 Desktop, no errors etc) but used the advice in from http://geekswithblogs.net/lbugnion/archive/2007/03/14/108728.aspx and wham! installed project was working..

try

{
  InitializeComponent();
}
catch ( Exception ex )
{
  // Log error (including InnerExceptions!)
  // Handle exception
}

I just had a good 4 hours trying to figure this out. Mine ended up being nothing to do with the xaml! Turned out it was a minor error in the code behind on MainWindow initialize.

If all else fails, check there

Uni

Cleaning and rebuilding the project was not effective for me.

You can try to delete bin Directory then rebuild, I solved my problem by this way.

I have got this problem. This problem occurs due to Microsoft.Expression.Drawing.dll please download dll and add reference.

I ran into this when working with multiple dlls running inside an application and those dlls have differing versions of the same dependency loaded.

We normally merge the dlls during our release build to prevent this issue, but we see it if we are testing more then one set of unmerged dlls during development cycle.

The solution it to only test one set of unmerged dlls, using merged release versions for the other dlls that are not being tested, or to ensure that the dependent dll is the same version for both sets.

I solved this problem by removing Sign the assembly, here :

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