I was initially using the following method - which was working fine
var obj = Activator.CreateInstance("MyProject","MyProject.MyImpl");
Now I am getting an error at the above line and the error is:
Exception has been thrown by the target of an invocation.
Any suggestions on what might be going wrong ?
The easiest would be to set a breakpoint in the constructor of the MyImpl
class and debug it.
One tricky problem you might be having is if the exception is actually not thrown directly by the constructor, but by some field initializer.
For example the following would cause the behavior you described, even though there is no explicit constructor that could throw anything.
public class MyImpl
{
private int something = ThisMethodThrows();
private int ThisMethodThrows()
{
throw new Exception();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With