method.invoke and TargetInvocationException

A

a

hi.

I am loading a program into memory and trying to run it (please don't
ask why or suggest something different)

Using this to do it:

http://www.codeproject.com/KB/cs/LoadExeIntoAssembly.aspx?display=PrintAll

It runs ok if I don't have a flash object on the form. If I do have
it, I get the error:

System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Threading.ThreadStateException: ActiveX control
'd27cdb6e-ae6d-11cf-96b8-444553540000' cannot be instantiated because
the current thread is not in a single-threaded apartment. at
System.Windows.Forms.AxHost..

Any idea what the problem is and/or how to solve it? I am using
[STAThread] above the Main call.
 
B

bradbury9

hi.

I am loading a program into memory and trying to run it (please don't
ask why or suggest something different)

Using this to do it:

http://www.codeproject.com/KB/cs/LoadExeIntoAssembly.aspx?display=Pri...

It runs ok if I don't have a flash object on the form. If I do have
it, I get the error:

System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Threading.ThreadStateException: ActiveX control
'd27cdb6e-ae6d-11cf-96b8-444553540000' cannot be instantiated because
the current thread is not in a single-threaded apartment. at
System.Windows.Forms.AxHost..

Any idea what the problem is and/or how to solve it? I am using
[STAThread] above the Main call.

Seems that you should create a new Apartment for the dinamic loaded
assembly before running it, check the SetApartmentState call in this
post: http://stackoverflow.com/questions/...-apartment-cannot-instantiate-activex-control
 
A

a

yup, that works, thanks.


hi.

I am loading a program into memory and trying to run it (please don't
ask why or suggest something different)

Using this to do it:

http://www.codeproject.com/KB/cs/LoadExeIntoAssembly.aspx?display=Pri...

It runs ok if I don't have a flash object on the form. If I do have
it, I get the error:

System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. --->
System.Threading.ThreadStateException: ActiveX control
'd27cdb6e-ae6d-11cf-96b8-444553540000' cannot be instantiated because
the current thread is not in a single-threaded apartment. at
System.Windows.Forms.AxHost..

Any idea what the problem is and/or how to solve it? I am using
[STAThread] above the Main call.

Seems that you should create a new Apartment for the dinamic loaded
assembly before running it, check the SetApartmentState call in this
post: http://stackoverflow.com/questions/...-apartment-cannot-instantiate-activex-control
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top