Assembly.CreateInstance throws "Exception has been thrown by the target of an invocation."

  • Thread starter Thread starter cristian
  • Start date Start date
C

cristian

I hope posting on this newsgroup is not such a big mistake, if so please
someone could redirect me to the right address?!

anyway, here is my problem,
On this line i receive an exception, that I wasn't able to find out where it
came from.

Assembly _formAssembly//just to show the type, it has been initialized
corectly

string _formClassName = path of the wanted assembly

Form frm = (Form)_formAssembly.CreateInstance_formClassName);

the inner exception has the message:"Object reference not set to an instance
of an object."

so far, I couldn't find which object is not an instance of an object.

has anyone a ideea of what is causing this?
thanks in advance!
 
I want to correct a typing error :

Form frm = (Form)_formAssembly.CreateInstance_formClassName);

Should have been

Form frm = (Form)_formAssembly.CreateInstance(_formClassName);

I hope posting on this newsgroup is not such a big mistake, if so
please someone could redirect me to the right address?!

anyway, here is my problem,
On this line i receive an exception, that I wasn't able to find out
where it came from.

Assembly _formAssembly//just to show the type, it has been initialized


string _formClassName = path of the wanted assembly

Form frm = (Form)_formAssembly.CreateInstance_formClassName);

the inner exception has the message:"Object reference not set to an
 
You're absolutely sure that _formAssembly is non null?

if so, catch teh exception and psint out the stack trace to see which method is throwing the exception. It may be the form's constructor or InitializeComponent

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

I want to correct a typing error :

Form frm = (Form)_formAssembly.CreateInstance_formClassName);

Should have been

Form frm = (Form)_formAssembly.CreateInstance(_formClassName);

news:<#[email protected]>...
 
Back
Top