.net – How to strong name an assembly that is shared by several developers

.net-assemblycomdelay-signnetstrongname

My colleagues and I have a C# project must be registered with COM using either regasm.exe or RegistrationServices for Excel interop. As a result, the assembly must be signed with a strong name key. A key file was generated through Visual Studio and committed to the source code repository.

Every time a new developer clones the git repository they must either go to the signing tab of the project properties and re-enter the password for the .pfx file or re-enter the password using sn.exe on the command line. Neither is ideal because both require manual steps and verbal communication of the (easy, widely known) password.

We tried delay signing the assembly which allowed the build to proceed but didn't let us register with COM.

Is there a way to do this without forcing everyone to manually update .pfx key files? Thanks!

Best Answer

[ComVisible] assemblies do not require a strong name. The default action for regasm.exe is to assume you'll deploy the assembly into the GAC. That is however not a requirement, give it the /codebase option to register it in the directory where it is located. Typically the build directory of the project.

This is also what Visual Studio does when you tick the "Register for COM interop" option in the Build properties. Now simply building the project is enough. Do check if this is still compatible with your installer. There are DLL Hell implications, best solved with isolation btw.