I'm very much a beginner with C# and the .NET Framework environment,
and am writing and building C# programs using the command line CSC.EXE
compiler. What I'm trying to do now is try out some of the evidence
options and the security policy settings.
Code Signing and using this via certificates and Publish evidence is
working fine, but I'm a bit stumped by strong naming at the moment.
I've created a key pair using sn.exe, and read that I sign with this
to an assembly before it's built (so not to a completed .exe).
This seems to be the way to go from what I've read:
AL.EXE /out:testapp.exe testapp.netmodule /keyfile:keypair.snk
So far I've been using /target:winexe in CSC.EXE, so don't have the
module files AL.EXE wants. I tried changing the CSC.EXE command line
to:
CSC.EXE /target.module /reference:... testapp.cs
This allowed AL.EXE to complete without error messages, but the
resulting .EXE says it's not a valid Win32 executable.
Can anyone point me in the right direction to getting a valid Win32
executable that is strong named, using only the command line tools of
the SDK?
Danny.
Bennie Haelen - 01 Sep 2005 17:52 GMT
Hi:
This should work:
1. Create your source file (e.ge. testApp.cs)
2. Create your keypair:
sn -k keypair.snk
3. Compile your source file into a .NET Module:
csc /target:module testApp.cs
this will create a file called testApp.netmodule
4. Use the assembly linker to create the .exe:
al /target:exe /out:testApp.exe /main:MyNamespace.testapp.Main
/keyfile:keypair.snk testApp.netmodule
Notice here that you should use the correct fully qualified name for
your main method: <NameSpace>.<className>.<MethodName>
Hope this helps,
Bennie Haelen
> I'm very much a beginner with C# and the .NET Framework environment,
> and am writing and building C# programs using the command line CSC.EXE
[quoted text clipped - 23 lines]
>
> Danny.
Danny Cooper - 02 Sep 2005 12:01 GMT
Excellent, yes that did it - except it didn't want the name space part
in the /main option.
Many thanks.
>Hi:
>
[quoted text clipped - 44 lines]
>>
>> Danny.