Exception has been thrown by the target of an invocation

  • Thread starter Thread starter Curious
  • Start date Start date
C

Curious

Hi,

I get the error, "Exception has been thrown by the target of an
invocation", at the last line of code.

Any idea why this happens and how to get it fixed?

Type mySFunction = Type.GetTypeFromProgID("S-
PLUS.rsi.em");

object splusObject =
Activator.CreateInstance(mySFunction);

object[] oArgs = new object[] { 33, 11, 56, 80 };

// Get error, "Exception has been thrown by the target
of an invocation"
splusObject.GetType().InvokeMember("x",
System.Reflection.BindingFlags.SetProperty, null, splusObject, oArgs);
 
There is no way for us to know what is wrong if we do not know what the
called function does. Can you link us to the API or control that you are
using, or at least describe the expected behavior?

In an essence, the error message means that the method you called raised an
exception. If in managed code, it could mean that the exception occurred in
the class contructor.

Hope this helps,
 
Back
Top