Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Exception has been thrown by the target of an invocation" error (mscorlib)

I have a website developed in ASP.Net 2.0 that is throwing the error

"Exception has been thrown by the target of an invocation"  

in the production environment. It was not throwing this error in development.

The source is 'mscorlib', and the stack trace says the error at

System.RuntimeMethodHandle._InvokeMethodFast. 

The only thing I've changed since my last upload to production is that I've started using Membership controls (Login, LoginView), and have added a few more stored procedures and tables, etc. The membership depends upon a custom provider I've written.

Anybody have a clue why this could be happening?

like image 901
Donnie Thomas Avatar asked Mar 15 '09 16:03

Donnie Thomas


People also ask

What does it mean when it says exception has been thrown by the target of an invocation?

Exception has been thrown by the target of an invocation. The full stack trace will be logged in the error log files. The most common causes for this exception could be a missing configuration or custom code in the custom MVC widget, during or post upgrades.


2 Answers

I'd suggest checking for an inner exception. If there isn't one, check your logs for the exception that occurred immediately prior to this one.

This isn't a web-specific exception, I've also encountered it in desktop-app development. In short, what's happening is that the thread receiving this exception is running some asynchronous code (via Invoke(), e.g.) and that code that's being run asynchronously is exploding with an exception. This target invocation exception is the aftermath of that failure.

If you haven't already, place some sort of exception logging wrapper around the asynchronous callbacks that are being invoked when you trigger this error. Event handlers, for instance. That ought to help you track down the problem.

Good luck!

like image 118
Greg D Avatar answered Sep 18 '22 17:09

Greg D


This can happen when invoking a method that doesn't exist.

like image 39
Casey Burns Avatar answered Sep 20 '22 17:09

Casey Burns