Re: error CS1548: Cryptographic failure while signing assembly

  • Thread starter Manuel J. Goyenechea
  • Start date
M

Manuel J. Goyenechea

Hello,

Up to this date I have had no problems building and deploying C#
ServicedComponents using Visual Studio 2003 .NET, but after removing a
registered object that had been testing I am no longer able to sign my C#
ServicedComponents. When I try to build the assembly I get the following
error:

error CS1548: Cryptographic failure while signing assembly
'c:\dev\dotnetsig\projects\02242004\tCom\obj\Debug\tCom.dll' -- 'The key
container name '..\..\tCom.snk' does not exist'

I have been to the MSDN site and have carefully looked into this error and I
have verified that the key tCom.snk which I generated using sn -k does exist
relative to the project in c:\dev\dotnetsig\projects\02242004\tCom and that
I am able to build without any problems if I do not define [assembly:
AssemblyKeyName("..\\..\\tCom.snk")] in AssemblyInfo.cs.

Below is a sample that duplicates the problem. Please advice as to what I
can do to resolve this problem.

Thanks in advance,

Manny


=================
tCom.cs
=================
using System;
using System.Reflection;
using System.EnterpriseServices;
using System.Runtime.InteropServices;
[assembly: ApplicationName("tCom")]
[assembly: ApplicationActivation(ActivationOption.Server)]
namespace acgnjdotnetsig
{
[Transaction(TransactionOption.Required)]
[ClassInterface(ClassInterfaceType.AutoDual)]
/// <summary>
/// Simple COM+ object.
/// </summary>
public class tCom : ServicedComponent
{
[AutoComplete]
public bool tmethod(string string1, string string2)
{
try
{
if(!ContextUtil.IsInTransaction)
{
throw new Exception("Not in transaction.");
}
if(!ContextUtil.IsCallerInRole("Administrators"))
{
throw new Exception("Not in Administrators.");
}
ContextUtil.SetComplete();
return true;
}
catch(Exception exception)
{
ContextUtil.SetAbort();
return false;
}
}
}
}


=================
AssemblyInfo.cs
=================
using System.Reflection;
using System.Runtime.CompilerServices;
//
// 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("tCom")]
[assembly: AssemblyDescription("Simple COM+ Component")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// 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 Revision and Build
Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0")]
//
// In order to sign your assembly you must specify a key to use. Refer to
the
// Microsoft .NET Framework documentation for more information on assembly
signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name)
utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET
Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("..\\..\\tCom.snk")]
 
M

Manuel J. Goyenechea

Hello,

Re:
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("..\\..\\tCom.snk")]

Found my bug, I had placed the snk file path in the key name in not in the
key file.

Manny

Manuel J. Goyenechea said:
Hello,

Up to this date I have had no problems building and deploying C#
ServicedComponents using Visual Studio 2003 .NET, but after removing a
registered object that had been testing I am no longer able to sign my C#
ServicedComponents. When I try to build the assembly I get the following
error:

error CS1548: Cryptographic failure while signing assembly
'c:\dev\dotnetsig\projects\02242004\tCom\obj\Debug\tCom.dll' -- 'The key
container name '..\..\tCom.snk' does not exist'

I have been to the MSDN site and have carefully looked into this error and I
have verified that the key tCom.snk which I generated using sn -k does exist
relative to the project in c:\dev\dotnetsig\projects\02242004\tCom and that
I am able to build without any problems if I do not define [assembly:
AssemblyKeyName("..\\..\\tCom.snk")] in AssemblyInfo.cs.

Below is a sample that duplicates the problem. Please advice as to what I
can do to resolve this problem.

Thanks in advance,

Manny


=================
tCom.cs
=================
using System;
using System.Reflection;
using System.EnterpriseServices;
using System.Runtime.InteropServices;
[assembly: ApplicationName("tCom")]
[assembly: ApplicationActivation(ActivationOption.Server)]
namespace acgnjdotnetsig
{
[Transaction(TransactionOption.Required)]
[ClassInterface(ClassInterfaceType.AutoDual)]
/// <summary>
/// Simple COM+ object.
/// </summary>
public class tCom : ServicedComponent
{
[AutoComplete]
public bool tmethod(string string1, string string2)
{
try
{
if(!ContextUtil.IsInTransaction)
{
throw new Exception("Not in transaction.");
}
if(!ContextUtil.IsCallerInRole("Administrators"))
{
throw new Exception("Not in Administrators.");
}
ContextUtil.SetComplete();
return true;
}
catch(Exception exception)
{
ContextUtil.SetAbort();
return false;
}
}
}
}


=================
AssemblyInfo.cs
=================
using System.Reflection;
using System.Runtime.CompilerServices;
//
// 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("tCom")]
[assembly: AssemblyDescription("Simple COM+ Component")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// 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 Revision and Build
Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0")]
//
// In order to sign your assembly you must specify a key to use. Refer to
the
// Microsoft .NET Framework documentation for more information on assembly
signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name)
utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET
Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("..\\..\\tCom.snk")]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top