HighTechTalks DotNet Forums  

.NET remoting and COM strange behavior

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss .NET remoting and COM strange behavior in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
zabutimaxim@gmail.com
 
Posts: n/a

Default .NET remoting and COM strange behavior - 07-02-2007 , 08:49 AM






Hi,

I have following strange problem. I run remote object using .NET
remoting.
This remoting object creates some COM object (STA) and executes some
methods.
The strange behavior is that if I print GetCurrentThreadId inside
remote object I see
that each call run in different thread id, but print from COM object
gives me same
thread id all the time. Under the stress it hase same exactly
behavior.
Can anyone explin me why it happens? Is there any article about this
in MSDN?

Thanks,
Maxim.


Reply With Quote
  #2  
Old   
Willy Denoyette [MVP]
 
Posts: n/a

Default Re: .NET remoting and COM strange behavior - 07-02-2007 , 12:13 PM






<zabutimaxim (AT) gmail (DOT) com> wrote

Quote:
Hi,

I have following strange problem. I run remote object using .NET
remoting.
This remoting object creates some COM object (STA) and executes some
methods.
The strange behavior is that if I print GetCurrentThreadId inside
remote object I see
that each call run in different thread id, but print from COM object
gives me same
thread id all the time. Under the stress it hase same exactly
behavior.
Can anyone explin me why it happens? Is there any article about this
in MSDN?

Thanks,
Maxim.


"Apartment" threaded objects cannot run on an MTA thread, they *must* run on
a STA thread, this is automatically taken care of by COM. That means that
your objects are getting created on a "COM" thread that is initialized to
enter an STA and your calls will get COM marshaled by a proxy/stub pair from
the MTA thread to the COM STA thread.
In order to prevent the marshaling overhead (and other marshaling related
issues), you should try to re-implement your COM objects as free threaded.

Willy.







Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.