1. 程式人生 > 實用技巧 >System.DllNotFoundException: Unable to load DLL 'wpcap' or one of its dependencies: 找不到指定的模組。 (0x8007007E)

System.DllNotFoundException: Unable to load DLL 'wpcap' or one of its dependencies: 找不到指定的模組。 (0x8007007E)

在NuGet安裝了SharpPcap5.3.0,並使用SharpPcap5.3.0編寫了程式,在本機執行是沒問題,但部署到另一部電腦就會報以下錯誤:

2020-10-22 16:37:17,273 [1] ERROR LogInfo - System.DllNotFoundException: Unable to load DLL 'wpcap' or one of its dependencies: 找不到指定的模組。 (0x8007007E)
   at SharpPcap.LibPcap.Windows.pcap_findalldevs(IntPtr& alldevs, StringBuilder errbuf)
   at SharpPcap.LibPcap.LibPcapSafeNativeMethods.pcap_findalldevs(IntPtr
& alldevs, StringBuilder errbuf) at SharpPcap.LibPcap.PcapInterface.GetAllPcapInterfaces() at SharpPcap.Npcap.NpcapDeviceList.Refresh() at SharpPcap.Npcap.NpcapDeviceList..ctor() at SharpPcap.Npcap.NpcapDeviceList.get_Instance() at SharpPcap.CaptureDeviceList..ctor() at SharpPcap.CaptureDeviceList.get_Instance()

查到是缺少了c:\Windows\System32\Npcap裡的wpcap.dll,而且安裝WireShark軟體就會有這個dll。我本機早就安裝了WireShark所以一直沒問題,其它沒安裝的就會報上邊的錯。

那麼使用NuGet安裝SharpPcap5.3.0程式設計的,在釋出時居然遇到坑了。

參考:https://stackoverflow.com/questions/58010149/unable-to-load-dll-wpcap-dll-the-specified-module-is-not-found