Wednesday 17 July 2013

ADDING STRONG NAME TO EXISTING DLL IN VS 2010

code :

Setting environment for using Microsoft Visual Studio 2010 x86 tools

Step 1 : Run visual studio command prompt and go to directory where your DLL located.

  For Example my DLL located in D:/Test.dll

Step 2 : Now create il file using below command.

  D:/> ildasm /all /out=Test.il Test.dll 
  (this command generate code library)

Step 3 : Generate new Key for sign your project.

  D:/> sn -k mykey.snk

Step 4 : Now sign your library using ilasm command.

  D:/> ilasm /dll /key=mykey.snk Test.il

so after this step your assembly contains strong name and signed. 


example done successfully :


C:\>ildasm /all /out=eCOS_ConnSharepoint.il eCOS_ConnSharepoint.dll

C:\>sn -k mykey.snk

Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Key pair written to mykey.snk

C:\>ilasm /dll /key=mykey.snk eCOS_ConnSharepoint.il

Microsoft (R) .NET Framework IL Assembler.  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.
Assembling 'eCOS_ConnSharepoint.il'  to DLL --> 'eCOS_ConnSharepoint.dll'
Source file is ANSI

Assembled method eCOS_ConnSharepoint.eCOS_fileLoader::UploadFileToDocLib
Assembled method eCOS_ConnSharepoint.eCOS_fileLoader::.ctor
Creating PE file

Emitting classes:
Class 1:        eCOS_ConnSharepoint.eCOS_fileLoader

Emitting fields and methods:
Global
Class 1 Methods: 2;

Emitting events and properties:
Global
Class 1
Writing PE file
Signing file with strong name
Operation completed successfully

C:\>gacutil.exe /i c:\eCOS_ConnSharepoint.dll
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Assembly successfully added to the cache

No comments:

Post a Comment