Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cryptographic failure while signing assembly in Visual studio

I don't know where I went wrong. When I build it searches for the default path for the DLL to sign in. Eventhough I specified the path.

I have created and stored my .snk file in the same location as the DLL.

//Assembly info file for errorcollection

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ErrorCollection")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ErrorCollection")]
[assembly: AssemblyCopyright("Copyright ©  2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components.  If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2c17131b-0ae3-4146-a797-308f5958e819")]

// Version information for an assembly consists of the following four values:
//
//      Major Version
//      Minor Version 
//      Build Number
//      Revision
//
// You can specify all the values or you can default the Build and Revision Numbers 
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: System.Reflection.AssemblyKeyFile(@"D:\Services\bin\ErrorCollection.snk")]

I get the following error:

"Cryptographic failure while signing assembly 'D:\Services\ErrorCollection\obj\Debug\ErrorCollection.dll' -- 'Error reading key file 'D:\Services\bin\ErrorCollection.snk' -- The system cannot find the file specified. ' ErrorCollection"

like image 591
Niranjan Thangaiya Avatar asked Nov 21 '10 08:11

Niranjan Thangaiya


3 Answers

Check the access rights to the Keys folder on the local machine and give permissions to the VS user.

C:\Documents and Settings\All Users\Application Data\Microsoft\Crypto\RSA\MachineKeys
like image 106
Stefan Michev Avatar answered Sep 21 '22 22:09

Stefan Michev


For me this problem happened after upgrading to windows 10. The location of the MachineKeys is then located at a different location namely

C:\ProgramData\Microsoft\Crypto\RSA

RightClick the MachineKeys and make sure all privileges are set.

like image 8
Philip Stuyck Avatar answered Sep 20 '22 22:09

Philip Stuyck


The path must be relative to the assembly.

Please check out the following knowledge base .

Hence try changing

@"D:\Services\bin\ErrorCollection.snk"

to be something like (here I am assuming it is four levels up to your root d drive)

@"..\..\..\..\Services\bin\ErrorCollection.snk"

like image 2
Ted Avatar answered Sep 21 '22 22:09

Ted