This project is read-only.

FileLoadException was unhandled

May 30, 2010 at 4:51 PM

I am using Visual C# 2010 and I started a new Windows Forms Application project.

I added the References to the pcapdotnet.dlls in the project. And added the following using statements.

using System.IO;
using PcapDotNet.Core;
using PcapDotNet.Packets;

In the form I added a button and inside the button_click method added the following line of code to retrieve the list of devices on my machine. I was then going to send the information to a listBox component for selection.

            IList<LivePacketDevice> allDevices = LivePacketDevice.AllLocalMachine;

I get the following error when I run the debugger and click the button.

FileLoadException was unhandled:

Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.


What do I need to do to use pcapdotnet in a Windows Form Application project?

All the examples seem to always use the console type of application. Could you add an example that is as simple as what I am trying to do?



May 30, 2010 at 5:21 PM
Edited May 30, 2010 at 5:31 PM

There is no difference between a Windows Forms Application and a Console Application when it comes to using Pcap.Net.

What version of Pcap.Net do you use?

Pcap.Net version 0.6.0 uses .NET Framework 3.5 SP1. If you want to use it you should change the target framework to 3.5.

If you want to use .NET 4.0 you should either wait for the next version of Pcap.Net (which will use .NET 4.0 only) or you should download changeset 46263 sources (under the Source Code tab) and compile them yourself (look at the developer's guide in the main page).


When I've upgraded Pcap.Net to Visual Studio 2010 and .NET 4.0 I've found out it is very incompatible with Visual Studio 2008 and .NET 3.5 (or lower versions).


I hope this helps.



May 30, 2010 at 7:38 PM

I changed my target framework to 3.5 client profile and the error went away.

I will continue to work under this setup and wait for the next release of Pcap.Net.


Jun 4, 2010 at 10:30 PM

Version 0.7.0 just got released. Now you can use .NET Framework 4.0 with Visual Studio 2010.