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 2004

Tip: Looking for answers? Try searching our database.

What are the problems when using CoRegisterClassObject/RegisterTypeForComClients in .NET?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Leon Finker - 14 Jul 2004 04:44 GMT
Hi,

Are there any problems with using CoRegisterClassObject/ROT in .NET/CLR to
expose an object as IDispatch for communication from/to unmanaged world? It
is registered from MTAThread. The DllImport is as follows:

[DllImport ("ole32.dll")]
static extern uint CoRegisterClassObject (ref Guid rclsid,
  [MarshalAs (UnmanagedType.IDispatch)]object pUnkn, ...);

I'm asking because .NET provides RegisterTypeForComClients() and it has the
following comment:
"This method, which is equivalent to calling CoRegisterClassObject in
COM...Using the RegisterTypeForComClients method can cause unpredictable
results, particularly if the application is multithreaded."

Could someone specify the "unpredictable results" referred to in the msdn
docs?

Thanks in advance
"Ying-Shen Yu[MSFT]" - 15 Jul 2004 04:40 GMT
Hi Leon,

To my understanding,  it meant that when you are making this call, we have
to make sure that no other thread is simutanously calling this method.

Calling CoRegisterClassObject directly may not be helpful to resolve this
problem, since this method also uses CoRegisterClassObject internally.

The doc also says that this API is not intended to be directly used in your
code, which makes it an unsupported API.

Thanks!

Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
Leon Finker - 15 Jul 2004 12:48 GMT
Thank you

> Hi Leon,
>
[quoted text clipped - 18 lines]
> This mail should not be replied directly, please remove the word "online"
> before sending mail.

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.