Unhandled exception. System.IO.FileLoadException

Hi,

I am getting the following error when running the code given on this page. I am using Python 3.8.2 and the latest available version of Aspose.Imaging for Python.

Error:

Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'System.Text.Encoding.CodePages, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)        
File name: 'System.Text.Encoding.CodePages, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at Aspose.WrpGen.Interop.ExchangeHost.InitServices()

Code:

import aspose.pycore as aspycore
from aspose.imaging import Image, Color
from aspose.imaging.fileformats.png import PngImage
from aspose.imaging.imageoptions import PngOptions


with aspycore.as_of(Image.load("input-image.png"), PngImage) as image:
	colors = image.load_pixels(image.bounds)
	length = colors.length
	for i in range(length):
		if i % 2 == 0:
			colors[i] = Color.red

	image.save_pixels(image.bounds, colors)
	image.save(os.path.join("result.png"), PngOptions())

Thanks.

@uax99
Hello! Thank you for your interest in Aspose.Imaging.
Could you please inform me what Operation System you use?

Please ensure you have dotnet-sdk-3.1 installed

Thanks for your reply.

I have installed .NET Core3.1 you have shared but still getting the same error. I am using Windows 11. Thanks

@uax99
As I can see in the error text the wrong version of System.Text.Encoding.CodePages is used.
I am going to reproduce this in a test environment.

Could you provide me an output of a command:
dotnet --list-runtimes

Here is the output:

Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Thanks

Hello, @uax99
Thank you for your patience and help.

After investigating your issue, we found out the following.

Since the Nugget repository marked the library System.Text.Encoding.CodePages.dll version 5.0 as outdated, into the Aspose.Imaging for Python via .NET 23.6 was injected a new dependency on the System.Text.Encoding.CodePages.dll version 7.0.2.
This issue has been added to our bug tracker with the number IMAGINGNET-6478 and will be fixed in the next version of the library.

As a temporary solution, we suggest you try to install .NET Runtime 7.0.2, which
can be found here Download .NET 7.0 (Linux, macOS, and Windows)

1 Like

@uax99
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): IMAGINGNET-6478

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like

Thank you. I will wait for the next release.

Hello @uax99
We are pleased to announce Aspose.Imaging for Python via .NET v23.7

We hope that your issues are resolved in this version.

1 Like

Thank you.

Do I just need to upgrade the package or is anything else required too?

UPDATE: I have upgraded the version to 23.7 and facing same issue.

Hello, @uax99
Sad to hear this. Unfortunately, we can not reproduce this issue on our test platform.
Could you install .NET Runtime 7.0.2 from Download .NET 7.0 (Linux, macOS, and Windows)
and test it again.
We are going to continue searching for the cause of such an error.