XamlParseException after deploying WPF project

2019-01-07 20:36发布

I have been trying to deploy my WPF app, I created a Setup Project using the Setup Wizard.The only Project Output I added was Primary. After building this and installing the program, as soon as i click the exe on my desktop i get a pop up that says "'My Program' has stopped working", so i click Debug the Program and i see

An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: 'Set connectionId threw an exception.' Line number '10' and line position '9'.

This exception does not point me in any direction as to what to fix. there is no 'connectionId' anywhere in my app.

I had previously ran into an XAMLParseException because of my NotifyIcon for my system tray, but this was fixed by adding the icon to the path of my exe. I thought this may be the problem so i added the icon to my Setup Project, along with all the other Project Outputs. Still Not Working.

I know this is a vague error but any help at all would be appreciated, my app won't run at all. Thanks!

10条回答
做自己的国王
2楼-- · 2019-01-07 21:26

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.

查看更多
对你真心纯属浪费
3楼-- · 2019-01-07 21:29

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.

查看更多
女痞
4楼-- · 2019-01-07 21:30

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
}
查看更多
The star\"
5楼-- · 2019-01-07 21:36

Cleaning and Rebuilding the solution might help!

查看更多
登录 后发表回答