Strong Names

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a third party .NET dll that has no strong name. Is it possible for me
to convert this into a dll with a strong name? I've looked quite extensively
at the docs w/r/t "al", "tlbimp", "regasm", and others to try to do this with
no success. Is this possible? Anyone have any ideas? Thanks.

Andy
 
from command line use:

sn -k keyfilename

to create the strong key pair.

then,

tlbimp weak.dll /keyfile:keyfilename /out:strong.dll

to create "strong" named dll
 
You should not sign any code you did not write yourself
with your strong name key pair. Instead you should obtain
a Primary Interop Assembly (PIA) from the author of the
component. You can create your own PIA for the component,
but the PIA guidelines clearly state that any interop
assembly that is not provided by the publisher of the COM
types is considered unofficial and should be avoided.
Because the types defined in such an assembly are not to
be signed by the publisher of the PIA, they are
incompatible with the definitions provided in the PIA.

If you still want to create a PIA for testing purposes
you can do the following:
1. If you haven't got a strong name key pair, create on
by using the strong name tool (sn.exe):
sn -k myKeyfile.snk
2. Create and sign a PIA for the component by using the
Type Library Importer (tblimp.exe):
tblimp
thridPartyComponent.dll /primary /keyfile:myKeyfile.snk /o
ut:unofficialThirdPartyComponentInterop.dll

For more information on PIAs see:
http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dndotnet/html/whypriinterop.asp

Anders Norås - senior consultant - Objectware
Blog: http://dotnetjunkies.com/weblog/anoras
 
Thanks for the message.

Unfortunately the company who wrote the developer dlls is stating that it
will take them a minimum of three months to sign the dlls and test
everything. I don't agree that it should be that difficult for them, and it
seems to be an error on their part that some of their dlls are strong and
only 2 out of ten are not...In any case, I've not been able to sway them.

With regard to your solution, I get an error stating:

"blah.dll is not a valid type library."

I'm assuming this has something to do with the fact that the dll is a .net
assembly. I've also tried to use ildasm and ilasm to disassemble and then
reassemble the dll with a strong name. This appears to cause problems
though. I install the signed dll in the gac and regasm it, but when i try to
use it in my program, the function within which it resides doesn't run, even
if I'm not hitting the lines that use the component (they are an else case
that doesn't get hit). Also, it doesn't throw an exception. The method just
doesn't run. If I comment the lines, the method runs fine. I don't
understand what's the problem. Anyone know what I'm doing wrong here???
Thanks in advance
 
Back
Top