Signing an Assembly with a Strong Name


I tried in signing in an assembly using the assembly linker.exe (al.exe)

This is the following cmd line which I have used in the command prompt
E:\Code Access Security\bin\Debug>al /out:Code Access Security.exe Code_Access_S
ecurity.Form1 /keyfile:sgkey.snk

and I am recieving the following error
ALINK: error AL1047: Error importing file 'E:\Code Access Security\bin\Debug\Acc
ess' -- The system cannot find the file specified.

The name of the source file which I am using is  form.cs
The name space I am using is Code_Access_Security
and the class is Form1.

please suggest me where I have went wrong and how can I resolve it.

Thanks in advance
Who is Participating?
davidlars99Connect With a Mentor Commented:
> I always just add the strong name key as an assembly attribute.

that's the proper way around if you have Visual Studio, but what if you don't? that's why I asked... if you don't have VS then, open command prompt window and do following:

C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.xxxx\Bin\al.exe /out:Code Access Security.exe Code Access Security.cs  /keyfile:sgkey.snk

you get "file not found" because you have "Code_Access_Security.Form1" what's Form1...??? it's not a valid extension is it..? that's why I replaced it with ".cs"

or you can compile all together and then sign it
C:\Program Files\Microsoft.NET\SDK\v1.xxxx\Bin\CSC.exe /t:library  /out:Code_Access_Security /r:System.dll,System.Data.dll,System.Drawing.dll,System.Web.UI.dll  Code_Access_Security.cs
try this

al /out:Code "Access Security.exe" Code_Access_S
ecurity.Form1 /keyfile:sgkey.snk

the space is probably causing the problem.
dnlakhaniAuthor Commented:
this doesn't work out ..

I have found another method where  I can do the same operation but I want to know why this does not work...!
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

do you have visual studio .net?

I always just add the strong name key as an assembly attribute.

Start> RUN> "C:\Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin\sn.exe" -k C:\temp\StrongName.snk

Then take the file and put it in the directory with all of the other source code.

Then add this assembly attribute:

[assembly: AssemblyKeyFile("..\\..\\StrongName.snk")]

Umm.. you shouldn't *have* to have visual studio to enter the strong name in as an assembly attribute (although it is easier).

I guess I haven't needed to test it, but the following code should work from within any text editor:

using System;


namespace MyApplication
   public class MyClass
       public MyClass(){}
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.