I want to add a registration-free COM reference to my .NET app. Registration-free means users can run the app without registering the COM component to their system.
I found a number of articles on this topic (e.g. MSDN, this S/O question, etc.) but none contains concrete steps. Here's what I have tried and did not work:
foo.dll
) using mt.exe as described in this answer.foo.dll
and foo.dll.manifest
to my app as "Build Action" = "Content" and "Copy to Output Directory" = "Copy Always".interop.foo.dll
that came with foo.dll
.Add app manifest file with this section:
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="foo" />
</dependentAssembly>
</dependency>
Build and run.
There's an error saying application configuration is not correct. Tried different values in <assemblyIdentity>
without luck.
Could someone share experience? Thanks.
Hans's answer has the right information, but I wasn't clear what to do when I first read it. After trying many different things I finally got it working and it's very simple:
By following these steps, the interop.foo.dll
and app manifest are automatically generated. This allows users to use the COM component without registration.
On the opposite, if you don't register the COM on the dev machine, you can still develop and build the app by adding reference to interop.foo.dll
(which can be generated on a machine with the COM class registered and then copied around), but the build result can only run on machines with the COM component registered. There might be a solution around this but requires deeper knowledge of how MSBuild work with COM references, which I did not spend time investigating.
So in short, the key to runtime registration-free COM is to register the COM class on the dev machine.