PdfSharp conflict exception

Answered
2
0

Hello,

I create a new program with the following actions:

  1. Create a new WiseJ application (Wisej 3 Web Application .NET Framework 4.8)
  2. Upgrade the Wisej 3 NuGet package to 3.5.22.
  3. Install the NuGet package PDFsharp 6.2.1.
  4. Add the line “PdfDocument outputPDFDocument = new PdfDocument();” in the function Program.Main().

The solution compiles well but the creation of a instance of PdfDocument generates the following exception:

Could not load file or assembly ‘Microsoft.Extensions.Logging.Abstractions, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Te same process with a Console App (.NET Framework 4.8) project generates no exception.

What can I do to avoid this exception?

Best regards

Edit: Add solution files example zip.

  • You must to post comments
Best Answer
1
0

It’s a dependency issue, not a Wisej issue.

The reason why it works in a console app and not in a Wisej app is because of this line here <Project Sdk="Microsoft.NET.Sdk.Web">

What this line does is that it essentially imports what is called a metapackage implicitly, named Microsoft.AspNetCore.App , and Microsoft.Extensions.Logging.Abstractions is part of it.

To fix it, add this to web.config:

	<runtime>
		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
			<dependentAssembly>
				<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
				<bindingRedirect oldVersion="1.0.0.0-9.9.9.9" newVersion="8.0.0.2"/>
			</dependentAssembly>
			<dependentAssembly>
				<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
				<bindingRedirect oldVersion="1.0.0.0-9.9.9.9" newVersion="6.0.0.0"/>
			</dependentAssembly>
		</assemblyBinding>
	</runtime>
  • Vincent Pfammatter
    Hello Julie, Yes, its works.. I didn’t know that the Microsoft.AspNetCore.App contains the Microsoft.Extensions.Logging.Abstractions. Thank you. Have a nice day
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.