Welcome Guest! To enable all features please Login or Register.



Go to last post Go to first unread
#1 Posted : Friday, August 30, 2019 11:45:49 AM(UTC)

Rank: Newbie

Groups: Registered
Joined: 8/17/2019(UTC)
Posts: 6
United Kingdom

Hi All,
I am evaluating Pdfium.Net.SDK for my customer. My solution is as follows:

Solution structure
1).NET 20 Standard Class library project (AnyCpu)
2).NET Framework 4.6.1 MS Test project (64 bit)
3).NET Console EXE 4.6.1 (64 bit)

The class library project has a Nuget reference to the latest Pdfium.Net.Sdk
The unit test project has a simple project reference to the Class library
When I try to execute a very simple unit test which invokes a class in the Class library, which in turn invokes Pdfium.Net.Sdk I encounter assembly loading failures.

The Console EXE works perfectly with .NET Standard 20 class library. The unit test not being able to load the assembly is becoming a major blocker.

Any suggestions?


If we change the class library project to target .NET Framework 461 instead of .NET Standard 20 then there is no problem. However, this adds on a new challenge. Our environment has a mix of .NET Framework and .NET Core and having a single .NET 20 library would be ideal.

Class library code

public class Class2
PdfDocument _doc;
public Class2(byte[] contents)
_doc = PdfDocument.Load(contents);


Unit test code

public void TestMethod1()
string file = @"C:\CS15.page6.pdf";
byte[] contents = System.IO.File.ReadAllBytes(file);
var c = new ClassLibrary1.Class2(contents);
catch (Exception ex)



Message=Could not load file or assembly 'Patagames.Pdf, Version=, Culture=neutral, PublicKeyToken=60fd6cf9b15941cf' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Fusion log
=== Pre-bind state information ===
LOG: DisplayName = Patagames.Pdf, Version=, Culture=neutral, PublicKeyToken=60fd6cf9b15941cf
LOG: Appbase = file:///C:/Truetemp/pdfium001/UnitTestProject1/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : ClassLibrary1, Version=, Culture=neutral, PublicKeyToken=null.
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\COMMUNITY\COMMON7\IDE\EXTENSIONS\TESTPLATFORM\testhost.x86.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Patagames.Pdf, Version=, Culture=neutral, PublicKeyToken=60fd6cf9b15941cf
LOG: Attempting download of new URL file:///C:/Truetemp/pdfium001/UnitTestProject1/bin/Debug/Patagames.Pdf.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Revision Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Edited by user Friday, August 30, 2019 12:24:39 PM(UTC)  | Reason: Not specified

#2 Posted : Wednesday, September 4, 2019 4:23:54 AM(UTC)

Rank: Newbie

Groups: Registered
Joined: 8/17/2019(UTC)
Posts: 6
United Kingdom

Hi all,
Please, were you able to reproduce this?

Paul Rayman  
#3 Posted : Thursday, September 5, 2019 5:39:37 AM(UTC)
Paul Rayman

Rank: Administration

Groups: Administrators
Joined: 1/5/2016(UTC)
Posts: 856

Thanks: 2 times
Was thanked: 103 time(s) in 101 post(s)

I'm not sure, but it looks like the TEST project cannot find the assembly file because the STANDARD20 project uses the new PackageReference format for the NuGet packages.
You can try one of the following:
1. Download the ZIP package instead of NuGet and add all the necessary files and dependencies to the STANDARD20 project manually.
Like described here: https://pdfium.patagames.com/help


2. You can implement the following workaround in the TEST project. I checked this way - works fine!
public class UnitTest1
    public void Workaround()
        AppDomain.CurrentDomain.AssemblyResolve += (s, e) =>
            return System.Reflection.Assembly.LoadFile(@"c:\PatagamesPdf\\net461\Patagames.Pdf.dll");

    public void TestMethod1()
        var cl = new Class1();

3. In your TEST project migrate package.config to PackageReference and modify NSTANDARD20 project settings as follows

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


    <PackageReference Include="pdfium.net.sdk" Version="4.15.2704">


Edited by user Thursday, September 5, 2019 7:41:08 PM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.