Signing an Assembly with a Strong Name

hi

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
LVL 1
dnlakhaniAsked:
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
0
 
zupi5Commented:
try this

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

the space is probably causing the problem.
0
 
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...!
0
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.

 
davidlars99Commented:
do you have visual studio .net?
0
 
_TAD_Commented:


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")]
0
 
_TAD_Commented:


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;

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

namespace MyApplication
{
   public class MyClass
   {
       public MyClass(){}
   }
}
0
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.