Paul Efford
Paul Efford

Reputation: 265

PcapDotNet System.IO.FileNotFoundException in Visual Studio

I have a C# solution (.Net 7.0) where I recently added the PcapDotNet libraries. Now I run the project and I keep getting this error:

System.IO.FileNotFoundException: 'Could not load file or assembly 'PcapDotNet.Core, Version=0.10.0.20632, Culture=neutral, PublicKeyToken=4b6f3e583145a652'. The system cannot find the file specified.'

I tried downgrading the target framework but still doesn't work.I know it's weird to say this, but it already worked "before". The project has no errors and I obviously need this library to work with network packages.

Any hints to solving this? Thanks in advance.

EDIT:

The issue arrises when I use the line if (communicator.ReceivePacket(out Packet packet) == PacketCommunicatorReceiveResult.Ok) where I am warned with The type 'Packet' is defined in an assembly that is not referenced. You must a reference to assembly 'PcapDotNet.Packets, Version=0.10.0.20603, Culture=neutral, PublicKeyToken=...'

The mentioned Packet class comes from using PcapDotNet.Core

Upvotes: 1

Views: 265

Answers (2)

Paul Efford
Paul Efford

Reputation: 265

I managed to solve it by downgrading the library to PcapDotNet (0.10.1), clicking on the project name on Visual Studio, and then deleting the code there and pasting instead this one:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>WinExe</OutputType>
    <TargetFramework>net7.0-windows</TargetFramework>
    <Nullable>enable</Nullable>
    <UseWPF>true</UseWPF>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="PcapDotNet" Version="0.10.1" />
  </ItemGroup>

</Project>

Upvotes: 1

Denis Kiryanov
Denis Kiryanov

Reputation: 871

Please make sure your project was built in Release mode and not Debug. Do not forget to check if this dependency really exists, with your particular PublicKeyToken and Version.

Also, please see the Using Pcap.Net in your programs guide and the FAQ (question #6).

Hope this helps.

Upvotes: 1

Related Questions