Re: I have the same problem
From: Chris Rolon (crolon_at_hotmail.com)
Date: 04/25/04
- Next message: Chris Rolon: "Re: WebServices and getting FileNotFoundException"
- Previous message: Ken Cox [Microsoft MVP]: "OT: IIS SSL Web server exploit warning"
- In reply to: jarod tupak via .NET 247: "I have the same problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Sat, 24 Apr 2004 22:42:13 -0700
One note: you should declare the Win32 method to get the last win32 error as
follows
<DllImport("advapi32.dll", SetLasetError := true)> _
Public Shared Function CryptAcquireContext( _
ByRef hProv As Integer, _
ByVal pszContainer As String, _
ByVal pszProvider As String, _
ByVal dwProvType As Integer, _
ByVal dwFlags As Integer) As Boolean
End Function
If false is returned, you then call
System.Runtime.InteropServices.GetLastWin32Error() to get the error code.
This will ensure that you get the correct error.
One more thing--why don't you use the managed classes for crypto? They are
much easier to use.
Chris Rolon
"jarod tupak via .NET 247" <anonymous@dotnet247.com> wrote in message
news:#qBcB9OKEHA.1264@TK2MSFTNGP12.phx.gbl...
> (Type your message here)
>
> I have the same problem when executing the code below. It returns me a
"126" error from kernel32.
>
> Dim sContainer as String = "sample_example_key"
> Dim sProvider as String = "myprovider"
> If Not (CryptAcquireContext(lHCryptprov, sContainer, sProvider,
PROV_RSA_FULL, 0)) Then
> MsgBox("Error " & GetLastError.ToString & " during
CryptAcquireContext!")
> End If
>
> <DllImport("advapi32.dll")> _
> Public Shared Function CryptAcquireContext( _
> ByRef hProv As Integer, _
> ByVal pszContainer As String, _
> ByVal pszProvider As String, _
> ByVal dwProvType As Integer, _
> ByVal dwFlags As Integer) As Boolean
> End Function
>
> Private Declare Function GetLastError Lib "kernel32" () As Long
>
> --------------------------------
> From: jarod tupak
>
> -----------------------
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
>
> <Id>hpmmaqsoTECdogXS0IdzeA==</Id>
- Next message: Chris Rolon: "Re: WebServices and getting FileNotFoundException"
- Previous message: Ken Cox [Microsoft MVP]: "OT: IIS SSL Web server exploit warning"
- In reply to: jarod tupak via .NET 247: "I have the same problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|