none
C# COM object and vbscript caller RRS feed

  • Question

  • I have been searching for literally days for a working recipe to create a COM object in C# that is callable from vbscript. Assume the signature for the C# function is something simple like:

    int ComExampleFunction(string parameter1, string parameter2)

    and the vbscript something simple like:

    dim objTest, intResult
    Set objTest = WScript.CreateObject ("ComExampleNamespace.ComExampleClass")
    intResult = objTest.ComExampleFunction ("string1", "string2")
    Wscript.echo "Result = " & intResult

    I am using VisualStudio 2019 but if COM is no longer supported there, I can revert to 2017.

    If you know of a working recipe I sure would appreciate a pointer to it.

    For example the latest example I tried ends up with error 80040154 on line 2 of the above script.




    Monday, April 22, 2019 7:21 PM

All replies

  • I have been searching for literally days for a working recipe to create a COM object in C# that is callable from vbscript. Assume the signature for the C# function is something simple like:

    int ComExampleFunction(string parameter1, string parameter2)

    and the vbscript something simple like:

    dim objTest, intResult
    Set objTest = WScript.CreateObject ("ComExampleNamespace.ComExampleClass")
    intResult = objTest.ComExampleFunction ("string1", "string2")
    Wscript.echo "Result = " & intResult

    I am using VisualStudio 2019 but if COM is no longer supported there, I can revert to 2017.

    If you know of a working recipe I sure would appreciate a pointer to it.

    For example the latest example I tried ends up with error 80040154 on line 2 of the above script.



    Monday, April 22, 2019 6:58 PM
  • Is there a reason you need vbscript rather than powershell?
    Monday, April 22, 2019 8:23 PM
  • COM error code 0x80040154 means "Class not registered".  So did you register your COM server?
    Monday, April 22, 2019 9:47 PM