HighTechTalks DotNet Forums  

how to create a com object using a progid read from config file

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


Discuss how to create a com object using a progid read from config file in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Benny
 
Posts: n/a

Default how to create a com object using a progid read from config file - 04-24-2007 , 06:44 PM






How to I create a COM object when all I have is a GUID that is read from an
ext config file and w/o using interop to raw WinAPI calls.

For example, I defined interface IFoo in a .net dll. I also have a
ServicedComponent that derives from IFoo named FooSvr.

In my .net client code, I want to create that object (of which the guid is
read programatically from a ext config file).

I want to do something like following in C#:
object o = CoCreateInstance(guid-read);
IFoo oFoo = o as IFoo;

Thanks.

Reply With Quote
  #2  
Old   
Walter Wang [MSFT]
 
Posts: n/a

Default RE: how to create a com object using a progid read from config file - 04-24-2007 , 09:52 PM






Hi,

You can use Type.GetTypeFromCLSID() to obtain a type from the CLSID, then
use Activator.CreateInstance() to create an instance from the type.

Here's an example in C# which is creating an instance of IE's
IInternetSecurityManager:

#IEBlog : IE Security Zones
http://blogs.msdn.com/ie/archive/2005/01/26/361228.aspx


Please feel free to let me know if there's anything unclear. Thanks.


Sincerely,
Walter Wang (wawang (AT) online (DOT) microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #3  
Old   
Walter Wang [MSFT]
 
Posts: n/a

Default RE: how to create a com object using a progid read from config file - 04-26-2007 , 09:37 PM



Hi,

Have you seen my last reply? Does it help?

Regards,
Walter Wang (wawang (AT) online (DOT) microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Reply With Quote
  #4  
Old   
Benny
 
Posts: n/a

Default RE: how to create a com object using a progid read from config fil - 04-30-2007 , 03:00 PM



Hi Walter, thank you very much. It is exactly what I am looking for.

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.