'Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.' after upgrading to latest

Hi,

We have been using Aspose.Html 20.11 for quite a while but due to incompatibility with the licnese we had to upgrade to latest version.
With the latest version though a simple code:

    Dim HtmlDocument As Aspose.Html.HTMLDocument = New Aspose.Html.HTMLDocument("file:///C:/Temp/test.html")

Fails with exception:
System.Reflection.ReflectionTypeLoadException: ‘Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.’

The LoaderException:
Could not load file or assembly ‘System.Drawing.Common, Version=4.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’ or one of its dependencies. The system cannot find the file specified.

Any idea how to avoid the problem would be appreciated!

@OleksandrKyiv

The error message you are encountering, “Unable to load one or more of the requested types,” typically indicates that there is an issue with a missing assembly or a version conflict after upgrading to the latest version of Aspose.Html. In your case, it seems that the assembly System.Drawing.Common is not being found, which is causing the exception.

To resolve this issue, you can try the following steps:

  1. Install the Required Assembly: Ensure that the System.Drawing.Common assembly is referenced in your project. You can add it via NuGet Package Manager by running the following command in the Package Manager Console:

    Install-Package System.Drawing.Common
    
  2. Check Version Compatibility: Make sure that the version of System.Drawing.Common you are using is compatible with the version of Aspose.Html you have upgraded to. Sometimes, newer versions of libraries may require specific versions of dependencies.

  3. Update NuGet Packages: If you haven’t already, consider updating all your NuGet packages to their latest versions. This can help resolve any conflicts that may arise from outdated dependencies.

  4. Review LoaderExceptions: If the issue persists, you can retrieve the LoaderExceptions property from the ReflectionTypeLoadException to get more detailed information about which specific types or assemblies are causing the problem. This can provide insight into what might be missing or incompatible.

  5. Check for Updates: Keep an eye on the release notes or updates from Aspose, as they may address known issues with specific versions. In some cases, users have reported that subsequent updates resolved similar problems.

If you follow these steps and still encounter issues, please provide additional details about your project setup, and I can assist you further.

Sources:
[1]: Conflicts on System.Drawing.Common for Aspose.HTML 23.4.0

Hi,

As I understand, the reply was genertaed by AI and doesn’t contain any real suggestion for solution, so it would be nice to get some real person to look at it :slight_smile:

Please notice it is a simple console application which fails now with the new version of Aspose.Html. The same application with the old version works as expected.

Notice, the project itself is Framework 3.5 project and installing latest nuget package is not an option.

Even if we believe Nuget package was the right thing to use, the latest Nuget package in 9.0.0.0 and Aspose.Html requires version 4.0.0.2.

All in all, som eother solutions are needed as the ones suggested by AI do not seem to be if any use.

@OleksandrKyiv

About the latest version of Aspose.HTML for .NET, please pay attention to the article .NET Standard - .NET | Microsoft Learn about .NET Framework compatibility with the netstandard 2.0. According to it Aspose.HTML for .NET is compatible with .NET Framework from 4.6.1 and higher. With some limitations described in that article.

Thanks for your reply. I’ve created a simple console app targetting .Net Framework 4.7.2 and got exactly the same error.
Application is really simple, I’ve added license file and reference to latest Aspose.Html and then invoked a very simple code:

    Dim Hl As New Aspose.Html.License()
    Hl.SetLicense("Aspose.Total.NET.lic")
    Dim HtmlDocument As Aspose.Html.HTMLDocument = New Aspose.Html.HTMLDocument("file:///C:/Temp/test.html")

@OleksandrKyiv

Looks like the issue is causing due to missing System.Drawing.Common assembly. We have tested in a VB Console Application by installing Aspose.HTML for .NET 24.11 through NuGet and did not notice any issues. Can you please share the same console application in .zip format where you are facing this exception?

ConsoleApp1.zip (2.6 MB)

Hi,

I have attached the sample application which fails.
Please notice I have removed license file from zip as I don’t think sharing it publicly is a good idea.

Debug.zip (538.8 KB)

@OleksandrKyiv

We have added attached two DLLs to your project to resolve the dependencies after updating the Aspose.HTML version to 24.11 and it worked without throwing any error.

I’m also running into the same issue and adding arbitrary DLLs to our build is very unlikely to be an acceptable solution. What other options are there? I tried adding a binding redirect to the NuGet package version of System.Drawing but didn’t have any luck with that either although the binding I added was a guess.

I took another stab at the binding redirect and got it working with this and the 9.0.0.0 NuGet package:

        <dependentAssembly>
			<assemblyIdentity name="System.Drawing.Common" publicKeyToken="CC7B13FFCD2DDD51" culture="neutral"/>
			<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0"/>
		</dependentAssembly>

@JonBakerHill

Its nice to know that you are able to resolve your issue. Please feel free to create a new topic in case you need any kind of assistance.