Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# EncrByElement类为空_C#_.net_Xml_Encryption - Fatal编程技术网

C# EncrByElement类为空

C# EncrByElement类为空,c#,.net,xml,encryption,C#,.net,Xml,Encryption,我正在尝试使用C#创建一个加密的XML文件。我举了一个例子: 我包括了对system.security.dll的引用,还包括了名称空间system.Xml、system.security.Cryptography和system.security.Cryptography.Xml,如示例所示 但是,该示例没有编译。EncryptedXml类似乎已被识别,但在下面的第二行,我收到了此错误:“'EncryptedXml'不包含'EncryptedData'的定义,并且找不到接受'EncryptedXm

我正在尝试使用C#创建一个加密的XML文件。我举了一个例子:

我包括了对system.security.dll的引用,还包括了名称空间system.Xml、system.security.Cryptography和system.security.Cryptography.Xml,如示例所示

但是,该示例没有编译。EncryptedXml类似乎已被识别,但在下面的第二行,我收到了此错误:“'EncryptedXml'不包含'EncryptedData'的定义,并且找不到接受'EncryptedXml'类型的第一个参数的扩展方法'EncryptedData'(是否缺少using指令或程序集引用?)

我可能错过了一些简单的东西。有人能给我指出正确的方向吗


编辑:我关闭并打开了Visual Studio,现在它可以工作了。。。谢谢您的帮助。

element-to-incrypt
是每个错误的错误类型,请验证它是否为
xmlement


public byte[]EncryptData(XmlElement inputElement,SymmetricAlgorithm,SymmetricAlgorithm,bool content)

elementToEncrypt和sessionKey是什么类型的?我关闭并重新打开了Visual Studio,现在它可以工作了。。。
...
EncryptedXml eXml = new EncryptedXml();
byte[] encryptedElement = eXml.EncryptData(elementToEncrypt, sessionKey, false);
...