The COMadapter in Attunity Connect supports the interaction with ActiveX objects. The adapter does not directly support .NET Assemblies.

Attempting to generate an adapter definition would result in the following error message:

Error loading type library/DLL. (HR=80029c4a)

The error indicates that the COMadapter failed in loading the typeLib at the autogen phase. The typeLib is where the metadata describing the object is stored.

A ‘genuine’ COM object records the typeLib location at the registry, hung nearby the CLSID node – thus enabling automatic identification of the typeLib associated with the object.

The .NET interop does not follow this convention. It does not provide the means Connect needs for identifying the typeLib via registry lookup.


STEP 1 - Writing COM friendly code.

Modifying the .NET Assembly to be COM friendly as follows:

Check the “Register COM Interop“ option in the Build Configurations. If you are using Visual .NET 2003, perform the followings::

Right-Click on the Solution.
Click on the “Configuration Properties“.
Click on the "Build" section.
Check the “Register for COM Interop“ checkbox.
There are two types of COM interfaces. By default, the COM interface that is generated from the .NET assembly is not compatible with many COM applications, like VisualBasic v6 and Connect's COMadapter.The solution is to let the .NET compiler generate the interface that most COM application can work with, which is the Dual interface.

This should be added per-class, by simply adding the following prefix to your public class:

Imports System.Runtime.InteropServices

' Applies the ClassInterfaceAttribute to set the interface to dual.
Public Class MyDotNetClass
End Class

Notice that the InteropServices should be imported in order for the code to be compiled.

STEP 2 - AUTOGEN Support for .NET Interop

The AutoGen feature of Attunity Connect was improved to allow the user to specify a typeLib file, which will overcome the problem which was mentioned earlier, where .NET does not record the typeLib in the registry.

Example of using the improved AUTOGEN syntax:

<AUTOGEN ProgId='sample_Prog_Id' typeLib=' ignoreList='Equals,GetHashCode,GetType,ToString'/>

Here is a short description of the properties marked in bold:

ProgId is an existing required field, which identifies the object both at run time and at “define time” (=autogen).
typeLib is an optional field where one can explicitly specify a typeLib that overrides the default (which is the one held in the registry).
IgnoreList is an optional field. It may hold a comma delimited (case sensitive) list of functions to be ignored upon adapter schema generation. It defaults to the internal interfaces contributed by .NET interop.


The DotNetTrig sample (attached) is the .NET version of the Trig COM sample located in the Attunity Connect installation. Follow these simple steps to create the DotNetTrig adapter on your machine:

Use the Studio and add a COMadapter called "DotNetTrig" to your selected binding. The following definition will be generated in the binding:
<adapter name='DotNetTrig' type='COM' definition='DotNetTrig'/>
Generate an "answer" file, which is an intermediate XML file specifying the adapter's configurations:
c:\DotNetTrig> nav_util autogen DotNetTrig -new answer.xml

Modify the answer file as follows:
<autogen ProgId='DotNetTrig.DotNetTrigCls' typeLib='D:\Support\COM\DotNetTrig\bin\DotNetTrig. tlb' ignoreList='Equals,GetHashCode,GetType,ToString'/>

Notice that you should specify the physical location to the typeLib file (tlb) generated when compiling your .NET Assembly with the COM Interop.

Automatically generate the Adapter's definition using the AUTOGEN facility:
c:\DotNetTrig> nav_util autogen DotNetTrig answer.xml

Refresh your daemon, and test the new Adapter using the XML Utility.