dotnet / pinvoke

A library containing all P/Invoke code so you don't have to import it every time. Maintained and updated to support the latest Windows OS.
MIT License
2.12k stars 222 forks source link

Can't dispose PInvoke.AdvApi32.SafeCryptographicProviderHandle #342

Closed aluferYochay closed 7 years ago

aluferYochay commented 7 years ago

Hi,

When trying to dispose the crypt handle I get from the call Crypt32.CryptAcquireCertificatePrivateKey I get the following exception:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.EntryPointNotFoundException: Unable to find an entry point named 'CryptReleaseContext' in DLL 'api-ms-win-service-management-l1-1-0.dll'. at PInvoke.AdvApi32.CryptReleaseContext(IntPtr hProv, UInt32 dwFlags) at PInvoke.AdvApi32.SafeCryptographicProviderHandle.ReleaseHandle() at System.Runtime.InteropServices.SafeHandle.InternalDispose() at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing) at System.Runtime.InteropServices.SafeHandle.Dispose()

Any idea why this is happening ? Can I work around it ?

Thanks