Link to home
Start Free TrialLog in
Avatar of SweatCoder
SweatCoderFlag for United States of America

asked on

How can I strong-name sign an assembly from the command line?

I cannot get this to work:

al /out:ProjectDoxCrypto.dll MyModule.netmodule /keyfile:IGC.snk

ProjectDoxCrypto.dll is a c# dll compiled with csc.exe within .NET 1.1, but I cannot get the line above to strong-name sign my assembly. I have no idea what "MyModule.netmodule" is referring to, so that's probably my problem. My IGC.snk file is in the same folder as the dll. The error I get when I run the line above is: "ALINK: error AL1016: No valid input files were specified".

What is an "input file" and how do I do this correctly?
Avatar of Tom Knowlton
Tom Knowlton
Flag of United States of America image

does IGC.snk already exist?

if so, how did you create the IGC.snk file?


command line to create the snk file is:

sn -k IGC.snk
Avatar of SweatCoder

ASKER

yes, that's how i created it. i believe the snk file is fine. since posting this, i have read a bit more and came to realize that a dll cannot be strong-named signed. i can only sign a "module", whatever that is, prior to compilation.

so PLEASE explain to me how i can take my .cs file, my .snk file, and produce a strong-named assembly. i need to use command line tools, not IDE (long story).

HELP.
You are not the author of the DLL?
It is:

ProjectDoxCrypto.dll


that you are trying to strongly name?
Yes, I am the author of it. I can compile the DLL just fine, but i can't give it a strong name via command line compilation, etc. The MSDN documentation doesn't explain very well, in the Assembly Linker docs, what a "module" is or how to create one. I suspect maybe a module is an IL file (not a compiled dll), but I'm not sure.

So just to recap. I have a cs file. It compiles fine into a dll using csc.exe. But I need the resulting dll to be strong-named signed using my IGC.snk file. That's all.

HOW?
Yes, ProjectDoxCrypto.dll, but I read somewhere in MSDN that once you've got a dll, it's too late to sign it. So signing must happen during or previous to the final assembly being created, somehow. . .
I haven't forgot about you....I'm still searching....

this is harder than I thought!
SOLUTION
Avatar of Tom Knowlton
Tom Knowlton
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I pretty much figured it out on my own, and then came back and saw your posts. Here's what I ended up doing:

C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\csc -t:module ProjectDoxCrypto.cs
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\al ProjectDoxCrypto.netmodule /target:lib /keyfile:IGC.snk /out:ProjectDoxCrypto.dll
%windir%\Microsoft.NET\Framework\v1.1.4322\RegAsm.exe .\ProjectDoxCrypto.dll /tlb:ProjectDoxCrypto.tlb
%windir%\Microsoft.NET\Framework\v1.1.4322\gacutil /i .\ProjectDoxCrypto.dll

All of this worked, and my poor dll finally landed in the gac, BUT, there is one annoying problem. The very first cmd-line above creates this file: "ProjectDoxCrypto.netmodule", and this file seems to need to stay in the same folder as the dll. It gets referenced, and I don't want it to be. I want the dll to be independant and not always have to have that IL file sitting there as a dependancy.

Any ideas?
Uuuugh.....maybe I'll look at this more tomorrow....gotta run my ride is here.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i ended up biting the bullet and installing VS.net 2003 and compiling with the snk linked, and then everything worked the way i wanted. i was hoping to get the cmd-line stuff working but never did. i guess i learned some things about those command line tools, so not a complete loss. thanks for the input.
Glad I could help.