Could not load file or assembly 'Aspose.Cells, Version=20.9.0.0, Culture=neutral, PublickeyToken

Have created a .dll where we using Aspose Cells and when run the program throw an Unhandled Exception HRESULT: 0X80131040. Mentioning that the located assembly’s manifest definition does not match the assembly reference.
I’ve tried other fixes that were mentioned on forum as Clean and Rebuild, or adding the System.Drawing.dll without any luck.

@Remus87,
You may please share your simple runnable solution which can be used here to reproduce the scenario and provide assistance accordingly.

bcreport_cells.zip (1.3 MB)
I’ve been running same executable project (The type of the project was Windows Application) an it worked fine (applied Aspose license) but had to convert the project into class library (.dll) to use it on a MapInfo environment and since I created a .dll it gives me the error . On the zip file I removed some of the libraries (.dll) among Aspose which were located on \bin\Debug just to decrease the size of the .zip to be sent to you.
I’m thinking now that is a class library it doesn’t have a starting point (Main) and maybe I need to change the location reference for the license. At the moment I am creating a class called LinemapBase.cs where I develop methods that will be called on 2 forms on the same project. I set the license in the constructor of LinemapBase.cs

Found a workaround -> copied the Aspose.dll on the same folder with the created .dll to be used (and where is the executable of the application where will be used).
Could use a better solution to save that space (the approx. 13MB size of the Aspose.dll) and to load aspose.dll as a resource from .NET platform rather than placing the dll file on the target application. If you have any ideas\solution will be welcomed. Thanks

@Remus87,
I have tried the scenario by adding the Aspose.Cells.Dll as embedded resource in the form based application and found it working fine. Could you please download the following solution and share the feedback. After compiling the solution just take out the output exe file and place it in some separate folder. When you will run this exe, it will create Excel file in the same folder because Aspose.Cells.Dll is embedded within this exe.

I have taken this sample solution from the following link:
https://www.codeproject.com/Articles/528178/Load-DLL-From-Embedded-Resource

Hi ! Thanks a lot for the provided solution. I’ve tried the scenario supplied and works ok. However in our case we are using a class library and don’t know exactly where to Load the assembly: EmbeddedAssembly.Load(“bcreport_cells.Aspose.Cells.dll”, “Aspose.Cells.dll”);
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
If you can suggest any idea where to include those two lines to call the Assembly will be great.

@Remus87,
Well apparently you may try following sample code and if requirement is not fulfilled, please try some resource on internet to achieve this functionality.

public class Class1
{
    public Class1()
    {
        EmbeddedAssembly.Load("Class1.Aspose.Cells.dll", "Aspose.Cells.dll");
        AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve);
    }
    static System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
    {
        return EmbeddedAssembly.Get(args.Name);
    }
}

Was including in the same place as you (In the constructor of the class where used aspose library) but apparently need to create a starting point to trigger the Load. Thanks a lot for the answer !