My application won't launch giving me some random error error when I haven't touched anything

StackOverflow https://stackoverflow.com/questions/1989158

  •  22-09-2019
  •  | 
  •  

Question

I'm having trouble debugging my application because I can't even run it. I haven't changed anything only added a picture to a folder in my solution explorer and now I can't even press F5 to debug it.

Here's the error:

System.Windows.Markup.XamlParseException was unhandled
Message=" Can't create instance of 'MainWindow' in the assembly.'testapp1 v0.1[WPF], Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'MainWindow.xaml' Line 1 Position 9."
Source="PresentationFramework"
LineNumber=1 LinePosition=9

I know this isn't much information but I'd really like to know if there is something clear I should be looking for. This is the first something like this has happened to me.


Edit: Here's the First lines of XAML code which are supposedly breaking my app.

<Window x:Class="Testapp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Tome of Newerth" Height="700" Width="900">
Was it helpful?

Solution

What happens when you remove the picture? Does it work again?

From the code you've posted it indicates that the error is in the code behind as it can't create an instance of the class.

What does the constructor of your MainWindow class look like.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top