How to implement a Remoting object which uses Activex control
-
Hi, I have a major problem in .Net Remoting.. I want to implement a ActiveX Control on Server Side but there seems no way out. Here is how i tried to implement it. 1) Created a form which containd the activex control 2) Implemented by a Class object inheriting System.MarshalByRefObject. 3) Created a instance of form in the class, like: public class Class1 : System.MarshalByRefObject { FormControl fc = new FormControl(); } and then tried to call it's member function on constructor. 4) on calling this object , from a server component implementing Remoting, it works fine. 5) but the problem comes now.. On implementing the client, a exception is thrown: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Threading.ThreadStateExc eption: Could not instantiate ActiveX control '11111111-7ba3-1111-9623-1111111 bd0' because the current thread is not in a single-threaded apartment. Please help me out.:confused::confused::confused::confused: Ashok Singh Real Programmer's do not comment their code, if it is hard to write then it should hard to understand
-
Hi, I have a major problem in .Net Remoting.. I want to implement a ActiveX Control on Server Side but there seems no way out. Here is how i tried to implement it. 1) Created a form which containd the activex control 2) Implemented by a Class object inheriting System.MarshalByRefObject. 3) Created a instance of form in the class, like: public class Class1 : System.MarshalByRefObject { FormControl fc = new FormControl(); } and then tried to call it's member function on constructor. 4) on calling this object , from a server component implementing Remoting, it works fine. 5) but the problem comes now.. On implementing the client, a exception is thrown: Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Threading.ThreadStateExc eption: Could not instantiate ActiveX control '11111111-7ba3-1111-9623-1111111 bd0' because the current thread is not in a single-threaded apartment. Please help me out.:confused::confused::confused::confused: Ashok Singh Real Programmer's do not comment their code, if it is hard to write then it should hard to understand
Try putting the following attribute in your client app. Remove the [STAThread] and put [MTAThread]. [MTAThread] static void Main() { Application.Run(new Form1()); }