method.invoke and TargetInvocationException

  • Thread starter Thread starter a
  • Start date Start date
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.
 
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
 
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
 
Back
Top