Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Presentation Framework Exception :(

Tags:

exception

wpf

So I am working on my final project for a summer course and I get this following exception.

An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in PresentationFramework.dll

Looking in the call stack, its doing all of its preprocessing, and it occurs. It isnt even starting my application so I dont think it could be my code. Is it possible I deleted some file on accident? My project was running fine. I made a few changes, one was adding a reference to a class I was going to use, but then changed my mind. I removed it, made some changes, and then went to run it, and bam! Yes, version control may of saved me from the issue, rookie mistake!

Any help is appreciated!

edit: there actually appears to be several exceptions, here is part of the output window

A first chance exception of type 'System.NullReferenceException' occurred in StockAnalysis.exe A first chance exception of type 'System.NullReferenceException' occurred in System.Xaml.dll A first chance exception of type 'System.NullReferenceException' occurred in PresentationFramework.dll A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in System.Xaml.dll A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in PresentationFramework.dll An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in PresentationFramework.dll

Additional information: Exception has been thrown by the target of an invocation.

like image 772
Teknos Avatar asked Jul 30 '11 04:07

Teknos


1 Answers

The TargetInvocationException almost always has InnerException set to something. Try to run it in Visual Studio so the exception dialog comes up, click the "View Details" link and you'll be able to expand the exception's properties to find out what really happened.

In 100% of the times I've gotten TargetInvocationException, its InnerException was not null. Most of the time (depending on your exception-handling), there's only the 1 InnerException.

It's a good rule to keep in mind: Always check InnerException.

like image 159
Joel B Fant Avatar answered Sep 28 '22 08:09

Joel B Fant