Vb.net 从x509到x5092的铸件
我不知道它认为我在哪里 这是我的财产Vb.net 从x509到x5092的铸件,vb.net,casting,x509certificate,Vb.net,Casting,X509certificate,我不知道它认为我在哪里 这是我的财产 ''' <summary> ''' Gets the GetX509Certificate from a file. ''' </summary> Private ReadOnly Property GetX509Certificate() As X509Certificate2 Get If m_X509Certificate I
''' <summary>
''' Gets the GetX509Certificate from a file.
''' </summary>
Private ReadOnly Property GetX509Certificate() As X509Certificate2
Get
If m_X509Certificate Is Nothing Then
'Should be able to use any of the "Create" methods in the namespace.
Dim path As String = "C:\Development\Workspaces\Productivity Framework\V07\Akcelerant.Connector.RouteOne.Web\Test.cer"
m_X509Certificate = X509Certificate2.CreateFromCertFile(path)
End If
If m_X509Certificate Is Nothing Then
Throw New ApplicationException("Certificate not found")
End If
Return m_X509Certificate
End Get
End Property
为什么这么说?所有内容都以正确的类型定义,但它仍然认为我在强制转换。CreateFromCertFile生成旧的对象类型。使用此方法,然后使用X509Certificate2构造函数进行强制转换。vb.net代码:
dim certificatePath as String = "c:\cert.cer"
Dim cert As X509Certificate2 = New X509Certificate2(X509Certificate.CreateFromCertFile(certificatePath))
dim certificatePath as String = "c:\cert.cer"
Dim cert As X509Certificate2 = New X509Certificate2(X509Certificate.CreateFromCertFile(certificatePath))