SUMMARY :
This article explains step by step of accessing COM+ application using C#. The code is compiled using beta2. Microsoft (R) Visual C# Compiler Version 7.00.9254 [CLR version v1.0.2914]. It can be used with Beta1 with some minor modification.
If we want need to access the existing COM+ application with any .net supported language, we don't need to modify the single line of exisiting COM+ application, despite of the fact their execution model is completely different. Here is the step-by-step easy example of doing the same. We can access it in two ways, Early Binding and Late binding (remembered the old VB concepts). We will first look at Early binding example.
Early Binding:
Tools Required:
TlbImp.exe: (Type Library Importer) Imports (converts, generates wrapper DLL) the type defination found in COM component into equivalent .net definations (or metadata), understandable by Common Language Runtime (CLR). The metadata generated, by TlbImp can be viewed by Ildasm.exe. If you are using the Visual Studio development environment, you only need to add a reference to the COM type library and the conversion is done automatically.
Let's Start:
To use exisiting COM+ application we need create Runtime Callable Wrapper (RCW) using TlbImp.Exe, with VS.Net it is created automatically, when we reference the exisiting COM Component. The difference is that, VS.Net create the RCW with the same name as the original DLL, which may be confusing, and with TlbImp.Exe, we can specify the different name using /out: parameter.

Let us assume that we have a COM Component with a method Add, which takes two parameter A and B and returns the Sum.
Note: We have to register COM DLL first before using it...
'CompAdd.Dll
(class1)




tonypowerPosted Jul 8, 2011, 8:33 AM
How can I get all method's name and it's parameters in late binding?
tonypowerPosted Jul 8, 2011, 8:32 AM
How can I get all method's name and it's parameters in late binding?