XAMLParseException driving me CRAZY!

笑着哭i 提交于 2019-12-01 15:52:40

I don't think this is really a XamlParseException: I think it's a TargetInvocationException which has gotten wrapped in a XamlParseException. Take a look at the ultimate inner exception:

NLog.Config.NLogConfigurationException Message=Exception occured when loading configuration from 'C:\Users\Mohit\Documents\Visual Studio 2010\Projects\Notepad\Notepad\bin\Debug\NLog.config'

It looks like you have a borked configuration file, possibly due to invalid XML or possibly for some more specific reason.

When you get a mysterious XamlParseException, it's always worth checking the InnerException for a TargetInvocationException (and drilling in from there if there is one). Yes, it is very confusing and misleading!

I know that this is an old question but hopefully this will help someone.

I had a property of the main window that was a Business Object... so when the window initialized, the Business Object attempted to initialize... great, but the Data access layer had not been setup, therefore it threw an error...

So c# called that an XML parse error because it happened so early... really it was thrown in code.

Solved the same issue by including the referenced dll and config files in the same folder as the exe file. Trying to run the exe alone will cause a windows level exception.

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