Wednesday 20 January 2010

Error: Exception has been thrown by the target of an invocation

In our BizTalk project, I have used a C# helper class, whose method uses Microsoft’s Enterprise Library to invoke a SQL-stored procedure. The SQL stored procedure does some data validation and raises errors for business validation errors using its RAISERROR keyword.

When our tester was testing the above application, they had this strange error

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> <<SQL Server’s error message>>

But the expected error is the <<SQL Server’s error message>> only  which has been appended wrongly with the strange error “System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation”

After spending sometime, I found out that the problem could be due to “Instrumentation” in Enterprise Library. So I installed the “Instrumentation” from

Start -> All Programs -> Microsoft pattern & practices -> Enterprise Library 3.1 – May 2007-> Install Instrumentation

It solved the issue.

0 comments: