Unable to locate the assembly

Hi all,

When I attempt to set the license file on Aspose.Pdf, I get the following exception:

System.TypeLoadException: Unable to locate the assembly '{b9cc24eb-6153-43c0-be92-3dc7de60b158}, PublicKeyToken=3e56350693f7355e' using the default probing methods.


Here is the code in which we set our license file

new Aspose.Pdf.License().SetLicense(@"C:\Utility\Objects\Install\Aspose.Total.lic");


We are using version 6.9.0.0 as that is the newest version we have access to with our current licensing agreement.


Usually, this type of exception would display the name of the assembly that it failed to load. Just having a Guid makes it close to impossible to figure out what the issue is.


Any help would be greatly appreciated.

Thanks,
Scott


PS. This only started happening when we upgraded to Aspose.Pdf.dll (v6.9.0.0) from Aspose.Pdf.Kit.dll (v5.7.0.0).

Hi Scott,

Thank you for the details.

Please send us your license file by following the steps mentioned in the below link for testing. We will check it and get back to you.

https://forum.aspose.com/t/how-to-send-license-file-to-support-team/225542

Sorry for the inconvenience,

Hi Scott,

Thank you for sharing the license file via email.

I checked your license file with the Aspose.Pdf for .NET v6.9 and I am unable to notice any problem. The license file works fine. Please share your system environment i.e. OS, .NET Framework, 32 bit or 64 bit machine (and if possible, please create a sample application and post it here). This will help us figure out the issue soon.

Sorry for the inconvenience,

In writing an app that simplifies the situation, I noticed that this only happens when setting the license occurs in a separate thread.



static void Main()
{
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
new System.Threading.Thread(SetLicense).Start();
Console.ReadKey();
}

private static void SetLicense()
{
new Aspose.Pdf.License().SetLicense(@“C:\Program Files (x86)\DSI Objects\Install\Aspose.Total.lic”);
}

private static Assembly OnAssemblyResolve(object sender, ResolveEventArgs args)
{
Console.WriteLine("Name: " + args.Name);
Console.WriteLine();
return null;
}

<span style=“line-height: 115%; font-family: “Tahoma”,“sans-serif”; font-size: 10pt;”>Hi Scott,

Thanks for sharing the details.

Please note that Aspose.Pdf initializes the license when first instance/object of Aspose.Pdf for .NET is created and its recommended to place the license initialization code n some static method which is executed once at that start of application. There is no need to re-initialize the license in multi-threaded environment when a new thread is created. The license is valid until the main application thread is running.

May be you can place the license initialization code in Main(), Page_Load() or any method which is executed at the start of application. In case you still face the similar problem or you have any further query, please feel free to contact. We are sorry for this inconvenience.

I will probably have to do your suggested solution and move where the license file is set.


However, consider the following:

A large company has 100+ applications that all process/manipulate/etc PDF files. They create a class library that uses Aspose.Pdf.dll as a utility component that all 100+ applications reference. It would make sense for them to set the license in the class library rather than the 100+ applications. In this scenario, would there be a better solution to the above problem?


Thanks for the guidance,
Scott
murphys811:
A large company has 100+ applications that all process/manipulate/etc PDF files. They create a class library that uses Aspose.Pdf.dll as a utility component that all 100+ applications reference. It would make sense for them to set the license in the class library rather than the 100+ applications. In this scenario, would there be a better solution to the above problem?
Hi Scott,

Sorry for the delayed response.

As per your understanding, if you are creating a class library which is referenced in all applications, you may initialize the license in Class library. However please note that individual application must instantiate and object of class library so that the license is initialized and all objects of Aspose.Pdf for .NET created in separate application have passed the license authentication. In case of any related query, please feel free to contact.