Reputation: 41
Background
I have two softwares, written in C#, using the same third-party dll to get telephony-capabilities.
Problem
When I deploy a new version of one of these softwares, I also deploy a new version of the dll. This one overwrites the references to the older dll, causing my other software to stop working, since the new dll isn't backwards compatible.
Attempted solutions
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools>sn.exe -e "theDll.dll" key
Microsoft (R) .NET Framework Strong Name Utility Version 4.0.30319.17929 Copyright (c) Microsoft Corporation. All rights reserved.
theDll.dll does not represent a strongly named assembly
This resulted in a "huh?". The dll works well however, so I don't want to look for a new vendor if I dont really have to.
C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools>ildasm.exe "theDll.dll" /out=theDll.il
error : 'theDll.dll' has no valid CLR header and cannot be disassembled
Which seems to imply that the dll is unmanaged, and thus not possible to strongly name (if I'm not mistaken).
Questions
Has anyone done this the "LoadLibrary"-way and can verify that it works well for a dll where you need to instantiate some classes?
Does anyone have a better solution?
Upvotes: 1
Views: 297
Reputation: 41
This instruction told me how to construct an appropriate manifest file for an unmanaged COM: https://msdn.microsoft.com/en-us/library/ms973913.aspx
A few important points I don't feel they covered so that I easily understood:
Oleview.exe is one way of getting the info you'll need for the manifest. It is possible to find your dll both by using Object classes-> All objects (provided it is registered with regsvr32) or by using File-> View TypeLib. I felt both these were needed before I had all information (they display different information).
When you have your manifest file, it is sufficient to chose "Add reference" in Visual studio, selecting the "Browse"-tag and then the COM-manifest you created. After that, programming is exactly as if the COM had been registered. VS will create the manifest for your program.
Of course you'll need to make sure your setup project deploys the .dll and its manifest to the same folder as your .exe.
Upvotes: 0