Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / July 2007

Tip: Looking for answers? Try searching our database.

.NET remoting and COM strange behavior

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zabutimaxim@gmail.com - 02 Jul 2007 13:49 GMT
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.
Christian Fröschlin - 02 Jul 2007 14:19 GMT
> This remoting object creates some COM object (STA) and executes some
> methods.
[quoted text clipped - 3 lines]
> gives me same
> thread id all the time.

By definition of STA, all calls to the COM object are executed
in the thread which *created* the object. Create an MTA object
if this is not what you want.
Willy Denoyette [MVP] - 02 Jul 2007 17:13 GMT
> Hi,
>
[quoted text clipped - 13 lines]
> 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.