Accessing COM type libraries from an OutSystems Extension

Accessing COM type libraries from an OutSystems Extension

  
If you are creating an OutSystems Extension that needs to access a COM library, follow these steps:


1. Register the COM library you need to access in your development machine. Open a command prompt and type:
regsvr32 COMLibrary.dll


2. Create a .NET stub to access the COM library. There are three ways of doing this:


2.1. Adding a reference from VS. Select Add Reference from the Solution Explorer in VS, click on the COM tab and select the registered COM to use. After including the using directive in the extension's code, the COM API can be used (in this case, the stub will be implicitly created).


2.2. Via Command Line. Open the Visual Studio command prompt and type:
tlbimp COMLibrary.dll /out:NETStub.dll
This will generate a .NET assembly named NETStub.dll, with the required API to access the COM library.


2.3. Using the oleaut32.dll to create the stub inside the OutSystems Extension code. See the attached file StubGenerator.cs for an example on how to do this.




3. Register the COM library in the server running the OutSystems Hub Edition. Open a command prompt and type the following:
regsvr32 COMLibrary.dll