0

I have a .net dll file called PcapNet.dll this file is a wrapper around C++ WanPacket.dll library.

But PcapNet.dll built with .net3.5, every time I reference it in modern .net application eg, .net 4.7

Shows me this message:

System.IO.FileLoadException: '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.'

Then I added

<supportedRuntime version="v2.0" sku=".NETFramework,Version=v2.0"/>

to App.config.

And This shows me the next message:

System.IO.FileLoadException: 'Could not load file or assembly 'PcapNet.dll' or one of its dependencies. A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A)'

Then I Changed TargetFrameWork to 3.5. And Now Everything worked correctly. And I Can use it.

But this is a big problem I can not stick with .net 3.5 I need 4.7 because I will use it in wpf application.

So how can i use this legacy library 3.5 with modern .net 4.7.

Notice: I do not have the source code of this library, I can only access the dll.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
  • Are you compiling your app in 32 or 64 bit mode? – mxmissile Feb 18 '20 at 18:48
  • 1
    Does this answer your question? [Mixed mode assembly is built against version ‘v2.0.50727′ of the runtime](https://stackoverflow.com/questions/6425707/mixed-mode-assembly-is-built-against-version-v2-0-50727-of-the-runtime) – the.Doc Feb 18 '20 at 18:50

1 Answers1

0

Using

<startup useLegacyV2RuntimeActivationPolicy="true">

Solved The Problem.