How to generate strong key name for an interop?
-
Hi, I have to build a layer of serviced components over a DAL (data access layer). Now this DAL was written using interop in VC++. I built my component using a snk - which worked fine till i added the code to access DAL. Now it gives me an error sayin that assemly cannot be created as DAL does not have a strong name. How do I get rid of this problem? How can i reuse the existing component without having to rewrite it in .net environment? I recently read an article sayin that i would have to generate a strong key for the interop dll using tlbimp... but i somehow am not able to figure the parameters out ... has anybody done this? Any help will be appreciated!
-
Hi, I have to build a layer of serviced components over a DAL (data access layer). Now this DAL was written using interop in VC++. I built my component using a snk - which worked fine till i added the code to access DAL. Now it gives me an error sayin that assemly cannot be created as DAL does not have a strong name. How do I get rid of this problem? How can i reuse the existing component without having to rewrite it in .net environment? I recently read an article sayin that i would have to generate a strong key for the interop dll using tlbimp... but i somehow am not able to figure the parameters out ... has anybody done this? Any help will be appreciated!
You only have to generate a strong name for interop if you plan to put the class library assembly into the GAC. This is recommended if you're going to share the component between applications, for example have multiple applications install the same component, but isn't actually required. The
regasm
utility can be made to register a class library DLL in any location using the/codebase
switch; the Visual Studio deployment project's Register property, if set to 'vsdraCOM', will set the Codebase registry value appropriately if you're not installing the assembly to the GAC. If you do install the same assembly from two different locations, then uninstall one of them, the registration will be broken for the other one. That's why the GAC is recommended. If you do want to use the GAC, all assemblies that this one depends on will need to be signed and installed to the GAC as well. You can sign the DAL using the C++ linker's/KEYFILE
option; you must specify this option in the 'Additional Options' field in the Linker options.Stability. What an interesting concept. -- Chris Maunder