Statically link COM DLL in C# (avoid regfree)

| | August 7, 2015

I have perhaps a silly question:

We have a VC++ COM DLL (developed internally) and we have ported our main app to C# and used COM Interop, reg-free to access the COM dll. Everything works just fine with internal embedded manifest.

However, the friendly product-dev/marketing/sales want to minimize the package and include the COM dll directly. Somehow, someone became convinced that the app distro should include the exe only (since it’s unmanaged we can’t just ILMerge it in).

Since we have the tlb/lib of the COM, could we somehow statically link it, without porting the whole COM to C# managed re-work?

Thank you

P.S. Pardon my wording: the company was downsized and I am the Python guy who had to learn everything .NET in the last week or so since now I am doing my job and the job of 2 ex-senior .net developers

One Response to “Statically link COM DLL in C# (avoid regfree)”

  1. It is possible to include the source for the COM DLL into the project for the exe, or you could change the COM DLL project into a static lib project. Once you’ve accomplished that, you must modify the code to create the COM objects directly. All said, neither options are particularly easy.

    Alternatively you could look into products like Spoon Studio that would allow you to wrap your exe and COM DLL into one exe without any code.

Leave a Reply