Dependency mismatch for NewtonSoft.Json versions? GroupDocs.Conversion has hard requirement for v12.0.3?

Noticed at compile time, GroupDocs.Total is okay with NewtonSoft.Json v13.
But at run time, when using GroupDocs.Conversion, it requires v12 instead?

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Could not load file or assembly ‘Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

@jarrodwee

Could you please specify the API (GroupDocs.Conversion for .NET) version that you are implementing in your application?

I’m using the latest GroupDocs.Total 23.4, not sure which GroupDocs.Conversion API version it is bundled with.

@jarrodwee
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): GRPDOCSTOTAL-23

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.

@jarrodwee

We need some more details. Could you please provide a sample project and share environment details (OS, target platform), because we could not reproduce this issue on our side.

To repro, comment out the “runtime” section in your test app’s config file:

image.png (17.6 KB)

Unfortunately, I’m using GroupDocs.Total within a host application whereby I don’t have the option of modifying the host app’s config file to perform runtime binding redirection.

@jarrodwee

We’ll continue our investtigation and will let you know if any further details are required.

@jarrodwee

We also need your development environment details. Could you please also share the URL of test project that you are evaluating?

Visual Studio 2019 on Windows 10.
Sample test project attached.

GroupDocs-Test.zip (11.6 KB)

1 Like

@jarrodwee

Thanks for the details. We’ll continue investigation and notify you in case of any update.

These links might help:

c# - Making binding redirects work for office add-ins - Stack Overflow

BindingRedirect in a addin config file - Add-in Express .NET forum (add-in-express.com)

1 Like

@jarrodwee

Thank you for sharing these links. We appreciate your help and will explore them to see how they can be helpful in our further investigations. Your contribution is valuable to us.

You’re welcome, was hoping to also help anyone else who might happen to encounter such issues and need to perform dynamic assembly binding in their project whereby they are not able to specify binding redirection in the application’s config file.

Meanwhile, I’ve updated the previously provided sample project’s Program.cs file pasted below for easy reference.

Interestingly, when running the below, it shows that there’s another DLL which cannot be resolved.
It appears that Aspose.PDF is referencing Aspose.Imaging and .NET is unable to resolve it.
However, I tested image conversion and it appears to work fine - but your dev team may want to look into it just in case.

Converting: C:\Projects\GroupDocs\GroupDocs\bin\Release\image.png
UNKNOWN requesting for Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
Loading >>> C:\Projects\GroupDocs\GroupDocs\bin\Release\Newtonsoft.Json.dll
Aspose.PDF, Version=22.9.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56 requesting for Aspose.Imaging, Version=22.9.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56
MISSING >>> C:\Projects\GroupDocs\GroupDocs\bin\Release\Aspose.Imaging.dll
using System;
using System.IO;
using System.Reflection;

namespace GroupDocsTest
{
    class Program
    {
        private static Assembly AssemblyResolve(object sender, ResolveEventArgs e)
        {
            try
            {
                Console.WriteLine($"{e.RequestingAssembly?.FullName ?? "UNKNOWN"} requesting for {e.Name}");

                var assemblyName = new AssemblyName(e.Name);
                var assemblyBasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                var assemblyPath = Path.Combine(assemblyBasePath, assemblyName.Name + ".dll");

                if (File.Exists(assemblyPath))
                {
                    Console.WriteLine($"Loading >>> {assemblyPath}");
                    return Assembly.Load(AssemblyName.GetAssemblyName(assemblyPath));
                }
                else
                {
                    Console.WriteLine($"MISSING >>> {assemblyPath}");
                    return null;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{ex.Message}");
                Console.WriteLine($"{ex.StackTrace}");
            }
            return null;
        }

        static void Main(string[] args)
        {
            if (args?.Length > 0 && !string.IsNullOrEmpty(args[0]))
            {
                AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve;

                string filePath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), args[0]);
                Console.WriteLine($"Converting: {filePath}");

                try
                {
                    using (GroupDocs.Conversion.Converter converter = new GroupDocs.Conversion.Converter(filePath))
                    {
                        GroupDocs.Conversion.Options.Convert.PdfConvertOptions options = new GroupDocs.Conversion.Options.Convert.PdfConvertOptions
                        {
                            PdfOptions = new GroupDocs.Conversion.Options.Convert.PdfOptions
                            {
                                PdfFormat = GroupDocs.Conversion.Options.Convert.PdfFormats.PdfA_2U
                            }
                        };

                        converter.Convert($"{System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filePath), System.IO.Path.GetFileNameWithoutExtension(filePath))}.pdf", options);
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"{ex.Message}");
                    Console.WriteLine($"{ex.StackTrace}");
                }
            }
            else
            {
                Console.WriteLine("File path not specified?");
            }
        }
    }
}
1 Like

@jarrodwee

Your insights and findings on this matter are greatly appreciated. Thank you for sharing these details, as they will undoubtedly prove valuable during our investigation.