How to use Invoke COM Method

The Invoke COM Method activity offers the possibility to call a Component Object Model (COM) method. This post shows how to create a COM library and to use it with the Invoke COM Method activity.


Build a COM library

We will start with the source code of an easy COM library. Here we define an interface and a class which are visible for COM, both get a GUID. In the interface the attribute InterfaceType is set to InterfaceIsDual, which means that it is useable for early and late binding. In the class we set the attribute ProgId, which specifies a more understandable name of the class. The class contains one method which delivers a tiny text back.


using System;
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyVersion ("")]
[assembly: AssemblyFileVersion ("")]
[assembly: ComCompatibleVersion(1,0,0,0)]
namespace Testing {

  public interface ITest {
    string TestMessage(string Msg);

  public class Test : ITest {

    public string TestMessage(string Msg) {
      if(String.IsNullOrEmpty(Msg)) {
        return "Hello World";
      } else {
        return "Hello " + Msg;




Now it is necessary to compile this library, to create a Dynamic Link Library (DLL). It is not necessary to install any additional software for that. The dotNET Framework contains all we need. All we have to do is to execute the following command in a console:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /target:library /platform:x86 /out:COMTest_x86.dll COMTest.cs

Now it is necessary to register the library in the Windows registry. All COM libraries are registered here. All we have here to do is to execute the following command in a console:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe /tlb:COMTest_x86.tlb /codebase COMTest_x86.dll

Independent Test with VBScript

To check our library we use a tiny test with a VBScript program.


'-Sub Main--------------------------------------------------------------
Sub Main()

  On Error Resume Next
  Set Test = CreateObject("Testing.Test")
  If Not IsObject(Test) Then
    MsgBox "Can't create Testing.Test", vbOkOnly, "Important hint"
    Exit Sub
  End If
  On Error Goto 0


End Sub



Here the use of the Program ID becomes visible, at CreateObject. If it works correctly we have done everything right. This functional test is very important and helpful, because it excludes further interfering factors.

Invoke COM Method

Now we can use the COM library with the method with Invoke COM Method. As you can see nothing else is done than in the VB Script. An object of a class with the program ID Testing.Test is created and the method TestMessage is called. The argument Msg is empty.



And it delivers exactly the expected result.


It’s all very simple, isn’t it.


As far as I can see an instance is created for each Invoke COM Method call. As far as I know, dependencies that refer to one object cannot be used on this way.

'Not possible
Set Test = CreateObject("Testing.Test")
Test.SetAttribute = 25

'That is the way
Set Test = CreateObject("Testing.Test")
Test.SetAttribute = 25

Set Test = CreateObject("Testing.Test")

It is possible to set properties via the BindingFlags, but unfortunately I have not found a way to apply this to one instantiated class. If anyone knows, please let me know.



Using Invoke COM Method actvitiy is very simple and easy to understand. On this way we are able to use a large part of methods from the COM universe on an easy way in our automation workflows. Via the COM interface we can also use these approaches in many other contexts. Not the fanciest way, but solid and consolidated.

Addendum 11.09.2022: The approach presented here is deprecated, because it can’t work in the Windows compatibility mode.