Hi All,
I am evaluating Pdfium.Net.SDK for my customer. My solution is as follows:
Solution structure1).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?
WorkaroundIf 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 codeQuote: public class Class2
{
PdfDocument _doc;
public Class2(byte[] contents)
{
_doc = PdfDocument.Load(contents);
}
}
Unit test codeQuote: [TestMethod]
public void TestMethod1()
{
string file = @"C:\CS15.page6.pdf";
try
{
byte[] contents = System.IO.File.ReadAllBytes(file);
var c = new ClassLibrary1.Class2(contents);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
ExceptionSystem.IO.FileLoadException
HResult=0x80131040
Message=Could not load file or assembly 'Patagames.Pdf, Version=4.4.6.2020, 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)
Source=SampleLib.Pdfium.NetSDK
Fusion log=== Pre-bind state information ===
LOG: DisplayName = Patagames.Pdf, Version=4.4.6.2020, Culture=neutral, PublicKeyToken=60fd6cf9b15941cf
(Fully-specified)
LOG: Appbase = file:///C:/Truetemp/pdfium001/UnitTestProject1/bin/Debug
LOG: Initial PrivatePath = NULL
Calling assembly : ClassLibrary1, Version=1.0.0.0, 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=4.4.6.2020, 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.