DreamTeK
DreamTeK

Reputation: 34287

Is not accessible in this context because it is friend

I pulled some code from another C# project and converted it to vb but now I get the error:

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

The namespace required is System.Deployment.Internal.CodeSigning but this namespace does not seem to have RSAPKCS1SHA256SignatureDescription.

The namespace that is being imported is System.Security.Cryptography but I am starting to think this is being derived from the wrong library.

Imports System.Security.Cryptography

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

Could anyone offer insight into this error message?

This error does not seem indictive of what Microsoft says it is:

Error ID: BC30389

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


Upvotes: 3

Views: 4056

Answers (1)

jmcilhinney
jmcilhinney

Reputation: 54457

Notice how the error message refers to System.Security.Cryptography.RSAPKCS1SHA256SignatureDescription? That's the class that your code is referring to and that class is declared Friend, so that's why you can't use it. If you want the System.Deployment.Internal.CodeSigning.RSAPKCS1SHA256SignatureDescription class then that's the namespace you need to import.


The System.Deployment namespace first needs adding to your project in order to reference the Internal.CodeSigning libraries.

enter image description here

Upvotes: 2

Related Questions