0

I am trying to call C# function from VB Script code, I am getting "Activex Component cant create object" error.

I have done the following.

  1. Created class library with ProgID, and Comvisible True and strong named
  2. Registered the dll using RegAsm.exe /codebase dllpath ( Dll registered successfully, I am able to see that in Registry)
  3. Creating object using VB Script code and calling C# function as below.
Option Explicit
Dim testwfhandler
Set testwfhandler= CreateObject("CoreComponentWorkflow.WorkflowHandler")
If Not testwfhandler Is Nothing Then
    Call testwfhandler.test()
End If
Set testwfhandler= Nothing

Am executing this VB Script from third party application (Tridion workflow) installed in my server.

Don't know why am getting the above error,when i execute the same code from the server directly, it works fine.

test() this function will just create one log file and add some text inside that.

Filburt
  • 17,626
  • 12
  • 64
  • 115
Jey
  • 2,137
  • 4
  • 22
  • 40
  • There are two versions of regasm.exe, a 32-bit and a 64-bit version. Matters on a 64-bit operating system, pick the right one. Or both. – Hans Passant Jul 11 '12 at 10:37
  • I am using the regasm.exe in C:\Windows\Microsoft.NET\Framework64\v4.0.30319 this location – Jey Jul 11 '12 at 10:51
  • The other one, C:\Windows\Microsoft.NET\Framework directory, home of the 32-bit version of .NET – Hans Passant Jul 11 '12 at 10:54

1 Answers1

3

The answer is already provided through the comments but I figured it makes sense to suppy a real answer so that others can easily find it back.

Depending on how your VBScript is loaded/executed you should register your DLL using the 32-bit or 64-bit version of RegAsm.exe.

On a 64-bit OS, you should find the 32-bit version of regasm in, C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe

and 64-bit version of regasm should be in, C:\Windows\Microsoft.NET\Framework64\v4.0.30319\RegAsm.exe

If you want to run the VBScript yourself in 32-bit mode on a 64-bit machine see How do I run a VBScript in 32-bit mode on a 64-bit machine?

Community
  • 1
  • 1
Bart Koopman
  • 4,835
  • 17
  • 30