?
Solved

Signing an Assembly with a Strong Name

Posted on 2005-04-28
7
Medium Priority
?
1,361 Views
Last Modified: 2011-04-14
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
0
Comment
Question by:dnlakhani
7 Comments
 
LVL 6

Expert Comment

by:zupi5
ID: 13892475
try this

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

the space is probably causing the problem.
0
 
LVL 1

Author Comment

by:dnlakhani
ID: 13892826
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
 
LVL 13

Expert Comment

by:davidlars99
ID: 13894603
do you have visual studio .net?
0
Free recovery tool for Microsoft Active Directory

Veeam Explorer for Microsoft Active Directory provides fast and reliable object-level recovery for Active Directory from a single-pass, agentless backup or storage snapshot — without the need to restore an entire virtual machine or use third-party tools.

 
LVL 22

Expert Comment

by:_TAD_
ID: 13897000


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
 
LVL 13

Accepted Solution

by:
davidlars99 earned 1500 total points
ID: 13897474
> 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
 
LVL 22

Expert Comment

by:_TAD_
ID: 13897823


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

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question