WPF Presentation Framework Exception :(

12,840

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.

Share:
12,840
Teknos
Author by

Teknos

Updated on June 13, 2022

Comments

  • Teknos
    Teknos about 2 years

    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.

  • Priyank Thakkar
    Priyank Thakkar about 10 years
    You saved my day joel.. :)
  • imba22
    imba22 over 7 years
    What if the inner Exception is null as well. I ran into this scenario