我正在尝试以编程方式从我的Yubikey的PIV中提取X509证书。我正在Windows 10上使用.NET标准2.0,我正在尝试安装和使用Yubico.Yubikey软件包(Yubico.Yubikey 1.3.1)。安装软件包并确保DLL被复制到bin目录后,我将运行我的应用程序并尝试运行SDK用户指南中的示例代码。
示例代码的第一行是:Dim yubikey = YubiKeyDevice.FindAll().First --但是,在执行这第一行时,我得到了一个不能加载的DLL异常。
System.DllNotFoundException: 'Unable to load DLL 'Yubico.NativeShims': The specified module could not be found. (Exception from HRESULT: 0x8007007E)'当然,没有将Yubikey.NativeShims DLL复制到我的bin目录(尽管我有一个Yubico.Core.dll、一个Yubico.Yubikey.dll和一个Yubico.DotNetPolyfills.dll)。即使在找到目标平台缺少的DLL副本并将其放入bin文件夹后,我仍然会得到此异常。
我遗漏了什么?
我在这里包含了来自异常的完整堆栈跟踪:
at Yubico.PlatformInterop.NativeMethods.SCardEstablishContext(SCARD_SCOPE scope, SCardContext& context)
at Yubico.Core.Devices.SmartCard.DesktopSmartCardDeviceListener..ctor()
at Yubico.Core.Devices.SmartCard.SmartCardDeviceListener.Create()
at Yubico.YubiKey.YubiKeyDeviceListener..ctor()
at Yubico.YubiKey.YubiKeyDeviceListener.<>c.<.cctor>b__34_0()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at Yubico.YubiKey.YubiKeyDeviceListener.get_Instance()
at Yubico.YubiKey.YubiKeyDevice.FindByTransport(Transport transport)
at Yubico.YubiKey.YubiKeyDevice.FindAll()
at ClassLibrary1.Class1.Work() in C:\Users\jzylkin\source\repos\WindowsApp3\ClassLibrary1\Class1.vb:line 6
at WindowsApp3.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\jzylkin\source\repos\WindowsApp3\WindowsApp3\Form1.vb:line 6
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)以下是vbproj项目
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>ClassLibrary1</RootNamespace>
<TargetFramework>netstandard2.0</TargetFramework>
<CopyLocalLockFileAssemblies>True</CopyLocalLockFileAssemblies>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Yubico.YubiKey" Version="1.3.1" />
</ItemGroup>
</Project>发布于 2022-06-23 06:55:22
杰克,
我提出了类似的问题。我刚刚将Yubico.NativeShims.dll重命名为Yubico.NativeShims (只需删除.dll扩展),它就起作用了。
沙龙
https://stackoverflow.com/questions/72014624
复制相似问题