Passing VB6 classes from dll to vb script through c#.net

460 Views Asked by At

I have a dll containing VB6 classes (.cls files).

I have a VB script that uses these classes.

I have a C#.Net program that runs the script using Microsoft Script Control library (Ref: http://osherove.com/blog/2004/2/17/make-your-net-application-support-scripting-a-practical-appr.html)

Here's my code:

script = new MSScriptControl.ScriptControl();
script.Language = "VBScript";
script.AddObject("MyClass", account, true);
script.AddCode(GetScriptCode());
script.ExecuteStatement("RunThisMethod");

MyClass is the C# equivalent of the VB6 class with [ComVisible(true)]

[ComVisible(true)]
public class MyClass
{ ... }

I would like to know if instead of creating my own C# classes that are visible to COM, would it be possible for my code to use the VB6 classes from the dll and pass it to the script and if yes, how?

Update: I have registered all the needed COM components and now I can reference the COM dll. However, when I try to instantiate an object of the class in COM dll, I get the error 80040154 Class not registered at run-time

0

There are 0 best solutions below