Failed to set license. Could not load assembly System.Windows- Version=2.0.5.0

After building out system with the latest version of Total for .NET, we’re now receiving the following error when trying to create a “Aspose.Imaging.Licence” object and set the license.

Failed to set license. Details: Could not load file or assembly ‘System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e’ or one of its dependencies. The system cannot find the file specified.
at Aspose.Imaging.License.SetLicense(String licenseName)
at Product.Pdf.Attachments.Processors.ImageProcessor.SetLicense()… (etc.)

The code causing the exception is:
public override void SetLicense()
{
License license = new License();
license.SetLicense(“Aspose.Total.lic”);
}

The second line causes the exception. SetLicense("…")

Out project is a .NET 4.0 project, so as expected, the only version of “System.Windows” available is v4.0.0.0.
The version of the “Aspose.Imaging.dll” is: 2.8.0.0 dated 08-FEB-2015

Hopefully someone knows how to resolve this version dependency.

Regards,
James.

Hi James,


Thank you for contacting Aspose support.

We have tried to replicate your presented scenario by setting the license in a console project targeted to .NET Framework version 4.0. Unfortunately, we are unable to replicate the said issue on our end so we need your help in identifying the problem cause. Please provide us a sample application replicating this issue along with all its dependencies. Please note, we do not need your license at this stage so please do not attach it in the forums.
I'm writing a .NET 4.5 Console Application. Sometimes when I call Aspose.Email.License.SetLicense I get an intermittent error with a very similar error message to the one originally reported. Here's the stack dump of the error:
System.InvalidOperationException was unhandled
HResult=-2146233079
Message=Failed to set license. Details: Could not load file or assembly 'zx_6dc133b2fe694166828c3c88a70d07b6, PublicKeyToken=716fcc553a201e56' or one of its dependencies. The system cannot find the file specified.
Source=Aspose.Email
StackTrace:
at Aspose.Email.License.SetLicense(String licenseName)
at Kutana.Kappris.Manipulation.PstHandler.VerifyLicence() in c:\Development\FB2476\Manipulation\Assembly\EmailHandler.cs:line 30
at Kutana.Kappris.Manipulation.PrintFu.VerifyLicences() in c:\Development\FB2476\Manipulation\Assembly\PrintFu.cs:line 700
at Kutana.Kappris.Manipulation.PrintFu..ctor() in c:\Development\FB2476\Manipulation\Assembly\PrintFu.cs:line 499
at Kutana.Kappris.Manipulation.Program.ExercisePrintFu(String[] args) in c:\Development\FB2476\Manipulation\ConsoleApp\Program.cs:line 98
at Kutana.Kappris.Manipulation.Program.Main(String[] args) in c:\Development\FB2476\Manipulation\ConsoleApp\Program.cs:line 18
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
I ran the fuslogvw tool and it tells me that every time the aspose email dll loads, the unusually named assembly zx_6dc133b2fe694166828c3c88a70d07b6 also loads. I'm pretty certain that the assembly is aspose-related because its PublicKeyToken is the same as other aspose assemblies:
*** Assembly Binder Log Entry  (18/12/2015 @ 11:54:34) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Development\FB2476\Manipulation\ConsoleApp\bin\Debug\ConsoleApp.exe
— A detailed error log follows.

=== Pre-bind state information ===
LOG: DisplayName = zx_6dc133b2fe694166828c3c88a70d07b6, PublicKeyToken=716fcc553a201e56
(Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: zx_6dc133b2fe694166828c3c88a70d07b6, PublicKeyToken=716fcc553a201e56 | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/Development/FB2476/Manipulation/ConsoleApp/bin/Debug/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = ConsoleApp.exe
Calling assembly : Aspose.Email, Version=6.0.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56.

LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Development\FB2476\Manipulation\ConsoleApp\bin\Debug\ConsoleApp.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Attempting download of new URL file:///C:/Development/FB2476/Manipulation/ConsoleApp/bin/Debug/zx_6dc133b2fe6Preformatted text94166828c3c88a70d07b6.DLL.
LOG: Attempting download of new URL file:///C:/Development/FB2476/Manipulation/ConsoleApp/bin/Debug/zx_6dc133b2fe694166828c3c88a70d07b6/zx_6dc133b2fe694166828c3c88a70d07b6.DLL.
LOG: Attempting download of new URL file:///C:/Development/FB2476/Manipulation/ConsoleApp/bin/Debug/zx_6dc133b2fe694166828c3c88a70d07b6.EXE.
LOG: Attempting download of new URL file:///C:/Development/FB2476/Manipulation/ConsoleApp/bin/Debug/zx_6dc133b2fe694166828c3c88a70d07b6/zx_6dc133b2fe694166828c3c88a70d07b6.EXE.
LOG: All probing URLs attempted and failed.

What is the zx_6dc133b2fe694166828c3c88a70d07b6 assembly, and why does it fail to load sometimes?
Hi Brian,

Please provide us a sample application replicating this issue along with all its dependencies. We will investigate it and update you accordingly.

This is an intermittent problem, and I don’t know what precise circumstances make it manifest. I did notice that sometimes when I build my project the problem is apparent, but then when I force the project to do an entire rebuild the problem goes away. I don’t have any more detail than that at the moment. It doesn’t matter so much at the moment as this behaviour is only on my development machine, and I can get it to go away by forcing the rebuild, but I’d like some assurance that this won’t start happening on end-user machines after we’ve released the product.


Brian

Hi Brian,

We have tested the issue at our end by running our sample application a number of times and no such issue is observed as such. Can you please try this on a different PC and share your feedback with us. This may help us identify the issue for assisting you further.