【问题标题】:How to use Pcap.Net in my project?如何在我的项目中使用 Pcap.Net?
【发布时间】:2014-05-07 13:07:38
【问题描述】:

我想在我的 C# 项目中使用 Pcap.Net。我下载并添加了对项目的 .dll 引用。

项目构建成功,但是当我运行它时,出现以下异常。

System.IO.FileNotFoundException was unhandled
  Message=Could not load file or assembly 'PcapDotNet.Core.dll' or one of its dependencies. The specified module could not be found.
  Source=trafcon
  FileName=PcapDotNet.Core.dll
  FusionLog=""
  StackTrace:
       at ObtainingTheDeviceList.Program.Main(String[] args)
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

我该怎么办?

【问题讨论】:

  • 你能检查一下 PcapDotNet.Core.dll 是否被复制到 bin Debug/Release 目录吗?
  • 您是在将项目标记为 x86 还是 x64?您使用的是正确的 x86/x64 dll 吗?
  • 你安装Winpcap了吗?

标签: c# pcap.net


【解决方案1】:

您可能没有在尝试运行此代码的机器上安装一个或多个PCap.Net 要求

这些要求(如this page of the PCap.Net project 所述)是:

  • WinPCap;
  • .NET Framework 4.0 或更高版本;
  • Microsoft Visual C++ 2010 可再发行包。

【讨论】:

  • 如果我已经安装了所有这些,但仍然出现错误可能是什么原因?
【解决方案2】:

无论您需要 x86 还是 x64,只需检查 .dll 的正确版本即可。或者根据你的.dll版本更改你应用的平台目标。

【讨论】:

    猜你喜欢
    • 2012-04-12
    • 2011-09-06
    • 2016-09-22
    • 1970-01-01
    • 2019-11-02
    • 2020-09-06
    • 2020-03-14
    • 2018-01-28
    • 2015-12-29
    相关资源
    最近更新 更多