In our MTS server, there are some component coded by VB6. Now I just try to
verify all component working fine, so I create an object for each component.
Using Type.GetTypeFromCLSID and Activator.CreateInstance (in C#) can create
object ONLY for .NET component.
My question is: How to Create an object of VB6 component in C#?
Thanks,
-Andrew
>In our MTS server, there are some component coded by VB6. Now I just try to
>verify all component working fine, so I create an object for each component.
>Using Type.GetTypeFromCLSID and Activator.CreateInstance (in C#) can create
>object ONLY for .NET component.
>My question is: How to Create an object of VB6 component in C#?
Activator.CreateInstance should work for pretty much any COM object,
including those written in VB6. If that's not what you're seeing,
perhaps you can tell us where it fails?
Mattias

Signature
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Andrew HUANG - 09 Nov 2007 22:56 GMT
Thanks, Mattias.
For library application, Type.GetTypeFromCLSID return System.__ComObject
instead of object name. After that, Activator.CreateInstance throws an
exception:
{"Retrieving the COM class factory for remote component with CLSID {} from
machine <ServerName> failed due to the following error: 80040154."}
From Microsoft: https://msdn2.microsoft.com/en-us/library/y76yy1s2.aspx
"Return Value
System.__ComObject regardless of whether the CLSID is valid. "
Would you give some advice for this issue?
Thanks,
-Andrew
> >In our MTS server, there are some component coded by VB6. Now I just try to
> >verify all component working fine, so I create an object for each component.
[quoted text clipped - 7 lines]
>
> Mattias