[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 an object of VB6 component in C#

Andrew HUANG

11/9/2007 2:22:00 PM

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
2 Answers

(Mattias Sjögren)

11/9/2007 10:12:00 PM

0


>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

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.n... | http://www.dotneti...
Please reply only to the newsgroup.

Andrew HUANG

11/9/2007 10:56:00 PM

0

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

"Return Value
System.__ComObject regardless of whether the CLSID is valid. "

Would you give some advice for this issue?

Thanks,
-Andrew

"Mattias Sjögren" wrote:

>
> >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
>
> --
> Mattias Sjögren [C# MVP] mattias @ mvps.org
> http://www.msjogren.n... | http://www.dotneti...
> Please reply only to the newsgroup.
>