[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.interop

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

Benny

4/24/2007 10:44:00 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.
3 Answers

wawang

4/25/2007 1:53:00 AM

0

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/3...


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


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

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default....
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/subscriptions/support/de....
==================================================

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

wawang

4/27/2007 1:37:00 AM

0

Hi,

Have you seen my last reply? Does it help?

Regards,
Walter Wang (wawang@online.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.

Benny

4/30/2007 7:00:00 PM

0

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