remoting configuration STA

C

cwineman

I am trying to create a remote object that instantiates an ActiveX control.
Apparently ActiveX controls can only be created in STAThreads. When I make
the following call from the client:

_myRemoteObject = (IRemoteObject) Activator.GetObject(
typeof(MyLib.IRemoteObject), host );

I keep getting the following error:

{"Could not instantiate ActiveX control
'd5b7f60a-c223-4556-845d-fe5f59e49f03' because the current thread is not in
a single-threaded apartment." }

I did some searching on the error and people seem to recommend starting
threads as STAThreads. But both my server and client were started as
STAThread. Something is happening when I make the GetObject() call. When I
step into the constructor for my remote object it says that I am in a MTA
thread.

Does anyone know what I am doing wrong? Is there something that I can put
into my remoting configuration file to specify that the remote object should
be created in an STAThread?

-Corey
 
W

Willy Denoyette [MVP]

cwineman said:
I am trying to create a remote object that instantiates an ActiveX control.
Apparently ActiveX controls can only be created in STAThreads. When I make
the following call from the client:

_myRemoteObject = (IRemoteObject) Activator.GetObject(
typeof(MyLib.IRemoteObject), host );

I keep getting the following error:

{"Could not instantiate ActiveX control
'd5b7f60a-c223-4556-845d-fe5f59e49f03' because the current thread is not
in a single-threaded apartment." }

I did some searching on the error and people seem to recommend starting
threads as STAThreads. But both my server and client were started as
STAThread. Something is happening when I make the GetObject() call. When I
step into the constructor for my remote object it says that I am in a MTA
thread.

Does anyone know what I am doing wrong? Is there something that I can put
into my remoting configuration file to specify that the remote object
should be created in an STAThread?

-Corey


You can't use ActiveX controls (Full controls or OCX's) in such scenarios.
Full controls, need an control container as host (that is a process that has
a UI and a form that hosts the AX control), your remote process is not such
an host I guess.

Willy.
 
C

cwineman

I see. I was afraid of something like that. I don't know that much
ActiveX/OCX controls, but I suspected that my problem was of the "you can't
get there from here" variety.

So it looks like I will have to have a process ( running the OCX control
with GUI and all) running on a remote machine and create my own mechanism
for communicating from clients with that process. Basically, to do
everything that .NET remoting does, without actually using the .NET remoting
framework.

Has anyone else done something similar? Can you recommend and tools,
libraries, or design patterns that were useful?
 

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