I have a situation that I need to determine if a particular version of com
component is present on user's machine from .NET.
In COM I would invoke CoCreateInstance(CLSID_MyComponent2_0) and if this
returns an HRESULT with REGDB_E_CLASSNOTREG I would know that this class is
not registered.
How can I achieve the same thing from .NET for the COM Component.
Regards & thanks
Kapil

Signature
Kapil Sachdeva
http://www.dotnetcard.com/blogs/ksachdeva
Mattias Sj?gren - 15 Jan 2005 01:34 GMT
Kapil,
>How can I achieve the same thing from .NET for the COM Component.
If you have an interop assembly for it you can simply try to new an
object of the COM class and catch the exception that is generated if
it's not registered. If you need it to work for a dynamic CLSID, you
can instead call
Activator.CreateInstance(Type.GetTypeFromCLSID(...clsid...)).
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.