How can I change the thread apartment when instancing a .Net Remoting active client type? -
02-19-2007
, 04:19 PM
When instancing a remote object (active client type), the current
thread apartment state is Unknown. I need to access an ActiveX control
inside this process and it requires a STA model. Both application
(Client & Server) are STA type by using the [STAThread] before the
Main();
Who can I change or instantiate the threat with a STA model for my
remoting object?
The System.Threading.Thread.CurrentThread.ApartmentSta te = Unknown in
the Initialize function.
Here is my code:
//**** Client ****
ChannelServices.RegisterChannel(new TcpChannel());
System.Runtime.Remoting.ActivatedClientTypeEntry entry = new
ActivatedClientTypeEntry(typeof(MapComponent), "tcp://localhost:302");
RemotingConfiguration.RegisterActivatedClientType( entry);
mapComponent = new TelDig.MappingTools.TdgMapComponent.MapComponent() ;
mapComponent.Initialize();
//**** Server ****
ChannelServices.RegisterChannel(new TcpChannel(302));
RemotingConfiguration.RegisterActivatedServiceType (typeof(MapComponent));
Thanks for the help. |