EvotecIT / PSPGP

PSPGP is a PowerShell module that provides PGP functionality in PowerShell. It allows encrypting and decrypting files/folders and strings using PGP.
MIT License
57 stars 21 forks source link

Bug using library with "Unable to find type [PgpCore.EncryptionKeys]" #1

Closed rakheshrao-shl closed 3 years ago

rakheshrao-shl commented 3 years ago

I am trying to use your excellent Module, however, I seem to be encountering errors like below:

WARNING: Protect-PGP - Can't encrypt files because: Unable to find type [PgpCore.EncryptionKeys].
WARNING: Protect-PGP - Can't encrypt files because: Unable to find type [PgpCore.EncryptionKeys].

I am stuck as this doesn't seem to want to go away. I am running this on Windows Server 2016. This is the output from the $PSVersionTable

$PSVersionTable

Name                           Value                                                                                                                                                          
----                           -----                                                                                                                                                          
PSVersion                      5.1.14393.4583                                                                                                                                                 
PSEdition                      Desktop                                                                                                                                                        
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                        
BuildVersion                   10.0.14393.4583                                                                                                                                                
CLRVersion                     4.0.30319.42000                                                                                                                                                
WSManStackVersion              3.0                                                                                                                                                            
PSRemotingProtocolVersion      2.3                                                                                                                                                            
SerializationVersion           1.1.0.1

I have tried this on 2 separate Windows Server instances and am encountering the same issue. Any idea what is going on and how to work around this issue?

rakheshrao-shl commented 3 years ago

So it looks like it might be a quick fix dependent on the code. Here is the fix possibly. https://stackoverflow.com/questions/42837447/powershell-unable-to-find-type-when-using-ps-5-classes

It maybe worth fixing things this way...

PrzemyslawKlys commented 3 years ago

Which version are you using? Installed from PSGallery?

PrzemyslawKlys commented 3 years ago

I've added tests to make sure things work - and they do. I've also released new version which changes a bit how things are loaded.

However I was able to reproduce your issue on Windows 2016

image

But when I added some diagnostic it's pretty clear it can't load net standard 2.0. Net Standard 2.0 works with Net Framework 4.6.1 as minimum.

image

Most likely you have not updated Windows 2016 to up-to-date net framework.

PrzemyslawKlys commented 3 years ago

From my testing it would seem you need 4.7.2 or so to be sure t works properly.

rakheshrao-shl commented 3 years ago

Yes I can confirm, this is now working. So all good. A thing to note for anyone reading this later, make sure you restart your system