Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there,

We are wondering what did we do to get such error message.
C#
Línea 54:             doc.LoadXml(documento);
Línea 55:             // Create a SignedXml object.
Línea 56:             SignedXml signedXml = new SignedXml(doc);
Línea 57:             // Add the key to the SignedXml document.  'key'
Línea 58:             signedXml.SigningKey = certificado.PrivateKey;

The project does have a reference to System.Security, and the namespace is also referenced in the class:
C#
using System.Security.Cryptography.XML;


Detailed compiler message goes (on and on) like this with every single file within
"HEFESTO...."
namespaces

warning CS0436: The type 'HEFESTO.CESION.LIB.Proxys.Certificacion.getSeedCompletedEventHandler' in 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\c8a68465\8993e0e1\App_Code.pobkvm1q.10.cs' conflicts with the imported type 'HEFESTO.CESION.LIB.Proxys.Certificacion.getSeedCompletedEventHandler' in 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\c8a68465\8993e0e1\assembly\dl3\7d1ae1d5\70825170_0bdfd201\CesionesRoot.DLL'. Using the type defined in 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\c8a68465\8993e0e1\App_Code.pobkvm1q.10.cs'


What I have tried:

We have deleted all files from them namespace and imported fresh copies from the original project, which runs.

Delete all contents of ASP.NET temporary files folder.

Rebuilt the entire project.

Removed and reload the System.Security reference.

If we comment out all three lines where we intent to create a SignedXml object, the error goes away, and the project runs. unfortunately, we MUST use SignedXml objects.

Any and all help is much needed and deeply appreciated. Thanks.
Posted
Updated 7-Jun-17 4:29am
v3
Comments
Karthik_Mahalingam 6-Jun-17 22:55pm    
try with namespace "System.Security.Cryptography.Xml.SignedXml"
alexvw 7-Jun-17 10:16am    
Hello Karthik, thank you for your suggestion; unfortunately, it makes no difference. After doing some more extensive reading I came across something that solved the issue. I will publish it as answer in a few minutes.

Cheers!
Karthik_Mahalingam 7-Jun-17 23:51pm    
cool.

Hello every body.

After reading some more, and trying anything I came across. I found an article that offered the so needed light at the end of the tunnel.

I knew the warning message I was getting from the compiler (at runtime) about the namespace had nothing to do with it, for the project would compile and run as long I did not try to instantiate a SignedXml object. The problem had to be isolated to the System.Security dll.

End of story, the article states that certain error "always happened while developing a web application in Visual Studio 2005 and wanting to use code that deals with certificates". Since I had nothing to lose, I gave it a try.

Solution
Modify the "Compilation" Tag in our Web.config file to include the following:

<assemblies>
        <add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>


at the end, it looks like this (and WORKS!!!):

<compilation debug="true" targetFramework="4.6.1">
      <assemblies>
        <add assembly="System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
      </assemblies>
</compilation>


No more
"warning CS0436....."
Cheers!
 
Share this answer
 
Comments
Karthik_Mahalingam 7-Jun-17 23:50pm    
good that you have posted it as solution, might be helpful for someone who needs it in future
You need add the dll reference:
System.Security.Cryptography.Xml

PM> Install-Package System.Security.Cryptography.Xml -Version 6.0.0

NuGet Gallery | System.Security.Cryptography.Xml 6.0.0[^]
 
Share this answer
 
Comments
CHill60 17-Jan-22 7:18am    
Please read Solution Number 1. The OP resolved this for themselves over 4 years ago

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900