Yubico.NET.SDK: Yubico.NativeShims breaks Powershell

With the implementation of Yubico.NativeShims (1.3.0), it is no longer possible (I cant find a way) to use the SDK for work with Powershell (which is based on .NET).

I have no problem adding the other DLLs, but Yubico.NativeShims gives the error: (PS 7.3):

Add-Type: Bad IL format. The format of the file 'C:\temp\yubico.nativeshims.1.5.2\runtimes\win-x64\native\Yubico.NativeShims.dll' is invalid.

(PS 5.1):

Add-Type : Could not load file or assembly 'file:///C:\temp\yubico.nativeshims.1.5.2\runtimes\win-arm64\native\Yubico.N
ativeShims.dll' or one of its dependencies. The module was expected to contain an assembly manifest.
At line:1 char:1
+ Add-Type -Path C:\temp\yubico.nativeshims.1.5.2\runtimes\win-arm64\na ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-Type], BadImageFormatException
    + FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.AddTypeCommand

This restricts usage of Yubico.Yubikey and Yubico.Core to version 1.2.0 or earlier.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (5 by maintainers)

Most upvoted comments

Hi @virot - sorry this has taken so long.

I originally though this might be related to #11 - however I realized that NuGet is probably not involved with your PowerShell project.

Am I correct in assuming that you were downloading the NuGet packages directly and then unpacking the assemblies by hand?

If that’s the case, I recommend copying out all of the assemblies into a common dependency directory. Since Yubico.NativeShims is a native DLL, you should not use “Add-Type” to import it, as there is nothing to import. Instead, the Yubico.NativeShims DLL should be placed in the same directory as the Yubico.Core assembly.

Keep in mind that the version of Yubico.NativeShims that you copy must match the processor architecture of the running PowerShell process.