在此上下文中无法访问,因为它是朋友

问题描述 投票:2回答:1

我从另一个C#项目中提取了一些代码,并将其转换为vb,但现在出现错误:

Is not accessible in this context because it is friend

Imports System.Security.Cryptography  

Public Shared Sub Sign()
  CryptoConfig.AddAlgorithm(GetType(RSAPKCS1SHA256SignatureDescription), "http://www.w3.org/2000/09/xmldsig-more#rsa-sha256")
End Sub

enter image description here

所需的namespaceSystem.Deployment.Internal.CodeSigning,但此命名空间似乎没有RSAPKCS1SHA256SignatureDescription

正在导入的名称空间是System.Security.Cryptography,但我开始认为这是从错误的库派生的。

Imports System.Security.Cryptography

Namespace System.Security.Cryptography
  Friend Class RSAPKCS1SHA256SignatureDescription
    Inherits RSAPKCS1SignatureDescription
    Public Sub New()
  End Class
End Namespace

任何人都可以深入了解此错误消息吗?

此错误似乎并不代表微软所说的是:

错误ID:BC30389

https://docs.microsoft.com/en-us/dotnet/visual-basic/misc/bc30389


asp.net vb.net webforms cryptography saml
1个回答
2
投票

注意错误消息如何指代System.Security.Cryptography.RSAPKCS1SHA256SignatureDescription?这就是您的代码所引用的类,并且该类被声明为Friend,因此这就是您不能使用它的原因。如果要使用System.Deployment.Internal.CodeSigning.RSAPKCS1SHA256SignatureDescription类,则需要导入该名称空间。


System.Deployment名称空间首先需要添加到您的项目中,以引用Internal.CodeSigning库。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.