Aspose.Imaging.License.SetLicence(stream) throws AmbiguousMatchException

Hi,
When reading in our licence file (as an embedded resource in our VisualStudio 2019 project) into a System.Stream object and calling SetLicence(stream) on the Aspose.Imaging.License, Aspose.Note.License and Aspose.Slides.License modules, an AmbiguousMatchException is thrown.

Dll versions:

  • Aspose.Imaging.dll - 19.9.0.0
  • Aspose.Note.dll - 19.7.0.0
  • Aspose.Slides.dll - 19.8.0.0
    (I did download the latest version 22.2.0.0 of Aspose.Imaging.dll and this still caused an exception.)

All our other Aspose modules load successfully.

We are targeting .NET Framework 4.8

This is a code snippet:
`public static void SetModuleLicences(string sLicence)
{
Assembly assembly = Assembly.GetExecutingAssembly();
using (Stream stream = assembly.GetManifestResourceStream(“PDFPrintManager.Resources.” + sLicence))
{
stream.Seek(0, SeekOrigin.Begin);
Aspose.ThreeD.License license3D = new Aspose.ThreeD.License();
license3D.SetLicense(stream);

    stream.Seek(0, SeekOrigin.Begin);
    Aspose.BarCode.License licenseBarCode = new Aspose.BarCode.License();
    licenseBarCode.SetLicense(stream);

    stream.Seek(0, SeekOrigin.Begin);
    Aspose.Cells.License licenseCells = new Aspose.Cells.License();
    licenseCells.SetLicense(stream);

    stream.Seek(0, SeekOrigin.Begin);
    Aspose.Cells.GridDesktop.License licenseCellsGridDesktop = new Aspose.Cells.GridDesktop.License();
    licenseCellsGridDesktop.SetLicense(stream);

    stream.Seek(0, SeekOrigin.Begin);
    Aspose.Diagram.License licenseDiagram = new Aspose.Diagram.License();
    licenseDiagram.SetLicense(stream);

    stream.Seek(0, SeekOrigin.Begin);
    Aspose.Email.License licenseEmail = new Aspose.Email.License();
    licenseEmail.SetLicense(stream);

    stream.Seek(0, SeekOrigin.Begin);
    Aspose.Imaging.License licenseImaging = new Aspose.Imaging.License();
    licenseImaging.SetLicense(stream);

    stream.Seek(0, SeekOrigin.Begin);
    Aspose.Note.License licenseNote = new Aspose.Note.License();
    licenseNote.SetLicense(stream);

    stream.Seek(0, SeekOrigin.Begin);
    Aspose.OCR.License licenseOCR = new Aspose.OCR.License();
    licenseOCR.SetLicense(stream);

    stream.Seek(0, SeekOrigin.Begin);
    Aspose.Pdf.License licensePdf = new Aspose.Pdf.License();
    licensePdf.SetLicense(stream);

    stream.Seek(0, SeekOrigin.Begin);
    Aspose.Slides.License licenseSlides = new Aspose.Slides.License();
    licenseSlides.SetLicense(stream);

    stream.Seek(0, SeekOrigin.Begin);
    Aspose.Tasks.License licenseTasks = new Aspose.Tasks.License();
    licenseTasks.SetLicense(stream);

    stream.Seek(0, SeekOrigin.Begin);
    Aspose.Words.License licenseWords = new Aspose.Words.License();
    licenseWords.SetLicense(stream);
}

}`

The exception stack trace is (which won’t be of much help I don’t suppose):
`System.Reflection.AmbiguousMatchException
HResult=0x8000211D
Message=Ambiguous match found.
Source=mscorlib
StackTrace:
at System.DefaultBinder.SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers)

This exception was originally thrown at this call stack:
System.DefaultBinder.SelectMethod(System.Reflection.BindingFlags, System.Reflection.MethodBase[], System.Type[], System.Reflection.ParameterModifier[])`

@jordan.walters We have checked and could succesfully apply license as embedded resource. Versions Aspose.Imaging.22.2. Please use our guide to do this Licensing|Documentation Related to questions on Aspose.Note.License and Aspose.Slides.License please refer to forums related to this products.

Hello Samer,
Thank you for such a quick response.
Our licence is for Total.NET and I use the same licence for all the modules I need.
I did as instructed on that page you linked, and used the name of the Embedded Resource “Aspose.Total.NET.lic”
Alas, the same 3 modules still raise that same exception.

    public static void SetModuleLicences(string sLicence)
    {
        Aspose.ThreeD.License license3D = new Aspose.ThreeD.License();
        license3D.SetLicense(sLicence);

        Aspose.BarCode.License licenseBarCode = new Aspose.BarCode.License();
        licenseBarCode.SetLicense(sLicence);

        Aspose.Cells.License licenseCells = new Aspose.Cells.License();
        licenseCells.SetLicense(sLicence);

        Aspose.Cells.GridDesktop.License licenseCellsGridDesktop = new Aspose.Cells.GridDesktop.License();
        licenseCellsGridDesktop.SetLicense(sLicence);

        Aspose.Diagram.License licenseDiagram = new Aspose.Diagram.License();
        licenseDiagram.SetLicense(sLicence);

        Aspose.Email.License licenseEmail = new Aspose.Email.License();
        licenseEmail.SetLicense(sLicence);

        Aspose.Imaging.License licenseImaging = new Aspose.Imaging.License();
        licenseImaging.SetLicense(sLicence);

        Aspose.Note.License licenseNote = new Aspose.Note.License();
        licenseNote.SetLicense(sLicence);

        Aspose.OCR.License licenseOCR = new Aspose.OCR.License();
        licenseOCR.SetLicense(sLicence);

        Aspose.Pdf.License licensePdf = new Aspose.Pdf.License();
        licensePdf.SetLicense(sLicence);

        Aspose.Slides.License licenseSlides = new Aspose.Slides.License();
        licenseSlides.SetLicense(sLicence);

        Aspose.Tasks.License licenseTasks = new Aspose.Tasks.License();
        licenseTasks.SetLicense(sLicence);

        Aspose.Words.License licenseWords = new Aspose.Words.License();
        licenseWords.SetLicense(sLicence);
    }

@jordan.walters could you also test setting license from the license file stream directly, not from an embedded resource, and doing it only for Aspose.Imaging? Does it still throw an exception this way?

Hi,
When I pass in the path/filename to the Imaging.SetLicence(), and after commenting out licence setting for all other modules - I still get the exception.
image.png (50.2 KB)

        public static void SetModuleLicences(string sLicence)
    {
        //Aspose.ThreeD.License license3D = new Aspose.ThreeD.License();
        //license3D.SetLicense(sLicence);

        //Aspose.BarCode.License licenseBarCode = new Aspose.BarCode.License();
        //licenseBarCode.SetLicense(sLicence);

        //Aspose.Cells.License licenseCells = new Aspose.Cells.License();
        //licenseCells.SetLicense(sLicence);

        //Aspose.Cells.GridDesktop.License licenseCellsGridDesktop = new Aspose.Cells.GridDesktop.License();
        //licenseCellsGridDesktop.SetLicense(sLicence);

        //Aspose.Diagram.License licenseDiagram = new Aspose.Diagram.License();
        //licenseDiagram.SetLicense(sLicence);

        //Aspose.Email.License licenseEmail = new Aspose.Email.License();
        //licenseEmail.SetLicense(sLicence);

        string sLicenceFileExplict = @"C:\Aspose.Total.NET.lic";
        Aspose.Imaging.License licenseImaging = new Aspose.Imaging.License();
        licenseImaging.SetLicense(sLicenceFileExplict);

        //Aspose.Note.License licenseNote = new Aspose.Note.License();
        //licenseNote.SetLicense(sLicence);

        //Aspose.OCR.License licenseOCR = new Aspose.OCR.License();
        //licenseOCR.SetLicense(sLicence);

        //Aspose.Pdf.License licensePdf = new Aspose.Pdf.License();
        //licensePdf.SetLicense(sLicence);

        //Aspose.Slides.License licenseSlides = new Aspose.Slides.License();
        //licenseSlides.SetLicense(sLicence);

        //Aspose.Tasks.License licenseTasks = new Aspose.Tasks.License();
        //licenseTasks.SetLicense(sLicence);

        //Aspose.Words.License licenseWords = new Aspose.Words.License();
        //licenseWords.SetLicense(sLicence);
    }

@jordan.walters We still can not reproduce your issue. Can you please try to request temporary license Temporary License - Purchase - aspose.com and check on it? Also, can you please share in archive your project for us and sent it via private message?

I’m not sure about being able to request a temporary licence as this looks like it will spark a trail of sales and marketing conversations which I don’t want to get into.
I can’t send you the project where this is failing - it’s huge, and our IP.
But I will endeavour to create a mini test project, and hopefully reproduce the failure.
The I can send you the project.
Would you still need OUR Aspose.Total.NET.lic for this, or could you test with your own?

It’ll be several days before I can do this because I have been diverted to another area in our product.

I shall be back soon.

Thank you once again, for your very quick responses. It is a refreshing change. :smiley:

Jordan

@jordan.walters, Ok, please give us sample project on which it can be reproduced, if you also will share it with your license, as we can not reproduce it on our, it may help us to reproduce issue and give suggestion.

Hello
Attached is a small example project for Visual Studio 2019, targeting .NET Framework 4.8.

(Unfortunately I am unable to attach the zip as your system complains it is too large. It is only 17MB and your system says it allows up to 50MB, but it rejects the zipped source. Instead, I have loaded it into my Dropbox Public folder. Here’s the link: Dropbox - File Deleted - Simplify your life)

Within the project, in the Resources sub-folder, are the 3 Aspose dlls I am referencing, and our licence file.

  • The AmbiguousMatchException issue for all 3 Aspose modules is reproducible, BUT ONLY IF DEBUGGING IN THE Visual Studio IDE.
    It does not manifest if you just click the .exe from File Explorer.

  • A further requirement to reproduce the issue is to switch on the particular Exception Setting in Visual Studio.
    This can be accessed from the VS2019 menu Debug/Windows/Exceptions Settings. Ensure that the “Common Language Runtime Exceptions → System.Reflection.AmbiguousMatchException” is ticked.
    See the attached Word doc which shows how to set the Exception capture.
    VS2019 Exception Settings.docx (98.9 KB)

Build and Debug the project from within VS2019 and you should encounter the exception.

Jordan

@jordan.walters Thank you for such detail description. We’ll check it and will notify you.

Hello
Any news on this?
Jordan

@jordan.walters
Hello.
We were able to reproduce the problem on the workstation of only one developer.
Also, apparently, this exception does not disrupt the library and is caught and handled inside the system libraries.
So for now, we can recommend just ignoring this exception in debugging.
As for the reason for this exception, work is underway to clarify it.

Hello
Is there any movement on a fix.
We do require this.
Thank you
Jordan Walters

@jordan.walters
Hello. Unfortunately, we do not have any changes in this issue.
Due to the high workload, we do not have enough resources for investigation and we do not consider it a critical problem.