如何在我的项目中使用Pcap.Net?

时间:2014-03-28 07:23:13

标签: c# pcap.net

我想在我的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: 

我该怎么办?

2 个答案:

答案 0 :(得分:0)

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

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

  • WinPCap;
  • .NET Framework 4.0 或更高版本;
  • Microsoft Visual C ++ 2010 Redistributable Package。

答案 1 :(得分:0)

只需检查.dll的正确版本是否需要x86或x64。或者根据您拥有的.dll版本更改应用程序的平台目标。

相关问题