Example on how to consume a COM server from a .NET client and a .NET server from a COM client. Examples are for both using the Registry and for RegFree.
This project is an example on how to manually consume a COM server from C# or a C# server from COM client. It also contains projects for less common scenarios involving .NET and COM.
Running COM server with Net client example:
ComInterop.sln
in Visual StudioDebug|x86
)ComServer.dll
) using regsvr32.exe
from an elevated command prompt
regsvr32.exe ComServer.dll
NetClient
project as the StartUp projectWhen done with the project, remember to unregister the COM server with regsvr32.exe
passing the /u
flag (e.g. regsvr32.exe /u ComServer.dll
).
Running Net server with COM client example:
ComInterop.sln
in Visual StudioDebug|x86
)NetServer.dll
) using regasm.exe
from an elevated command prompt
regasm.exe NetServer.dll /codebase
/codebase
flag adds the current path of the assembly to the registryComClient
project as the StartUp projectWhen done with the project, remember to unregister the Net server with regasm.exe
passing the /u
flag (e.g. regsvr32.exe /u NetServer.dll
).
Projects demonstrating Registration Free (RegFree) COM are also included.
Running the RegFree COM server with Net client example:
ComInterop.sln
in Visual StudioDebug|x86
)
AnyCPU
and x86
platforms in RegFree COM.NetClient_RegFree
project as the StartUp projectRunning the RegFree Net server with COM client example:
ComInterop.sln
in Visual StudioDebug|x86
)ComClient_RegFree
project as the StartUp projectRunning the Out-of-proc demo:
ComInterop.sln
in Visual StudioDebug|x86
)OutOfProcDemo
project as the StartUp projectNote The Out-of-proc demo launches a child process from the main process.