HighTechTalks DotNet Forums  

How to Create an object of VB6 component in C#

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


Discuss How to Create an object of VB6 component in C# in the Dotnet Framework (Interop) forum.



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

Default How to Create an object of VB6 component in C# - 11-09-2007 , 09:22 AM






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

Reply With Quote
  #2  
Old   
Andrew HUANG
 
Posts: n/a

Default Re: How to Create an object of VB6 component in C# - 11-09-2007 , 05:56 PM






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

"Mattias Sjögren" wrote:

Quote:
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.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.


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.