Вопрос

I have 6 old VB6 DLLs that need to work with my application. To have them work in .NET land, they were converted to Interop DLLs.

One of the Interop DLLs (call it Master.DLL) references the other 5 DLLs.

I wanted to strongly-name Master.DLL so I used ildasm/ilasm with a .SNK file

When I open the newly strong-named Master.DLL with ildasm and look at the manifest, its five references aren't strongly named, causing FileLoadExceptions.

My question: is it possible to strongly-name an Interop DLL AND all its assembly references in the manifest with the same .SNK file using ildasm/ilasm??

Это было полезно?

Решение

This requires decompiling the interop libraries with ildasm.exe, then strong naming the DLLs, then putting humpty dumpty back together with ilasm.exe so they'll use the strong name in their .assembly directives.

This is painful and not that easy to automate. Do strongly consider the usefulness of doing this, it is rather a low one. It is only ever truly required when you need to generate PIAs and install them in the GAC. Which is only ever necessary if the client assemblies that use these interop libraries expose the VB6 interfaces themselves and those client assemblies are in turn used by another app. That's rare.

The much superior solution is to use the "Embed Interop Types" feature, available in VS2010 and up. Otherwise known as the "No PIA" solution. Which completely eliminates the need for these interop libraries, the [ComImport] types get embedded in the client assembly. The "Type equivalence" feature in .NET 4.0 and up ensures that having these types embedded in multiple assemblies do not cause a problem, they are considered identical when the [Guid] matches, regardless of what assembly they came from. And of course you would not have any trouble strong-naming those. That's a long of bang for the buck.

Другие советы

You may try creating interop dlls by calling tlbimp yourself. It will save you the ilasm/ildasm path btw.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top