I am unable to use Aspose PDF methods in my MSTest methods.
Here is a rough overview of how the error is produced:
lic.SetLicense("Aspose.Total.lic");
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(GetResourcePdfStream());
TestPdfStream = new MemoryStream();
doc.Save(TestPdfStream);
The above lines of code produce the following error only when I run this in an MSTest context
Message:
Initialization method dox42CoreUnitTests.PdfGeneratorUnitTests.SetUp threw exception. System.IO.FileLoadException: Could not load file or assembly β{9a502237-0d97-41a6-89f5-699fc103b592}, PublicKeyToken=3e56350693f7355eβ or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) β> System.ArgumentException: The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)).
Stack Trace:
AppDomain.nApplyPolicy(AssemblyName an)
AssemblyResolver.OnResolveInternal(Object senderAppDomain, ResolveEventArgs args, Boolean isReflectionOnly)
AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
β End of inner exception stack trace β
RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
Assembly.Load(String assemblyString)
Β2.ΒΒ(Object , ResolveEventArgs )
AppDomain.OnResourceResolveEvent(RuntimeAssembly assembly, String resourceName)
RuntimeAssembly.GetResource(RuntimeAssembly assembly, String resourceName, UInt64& length, StackCrawlMarkHandle stackMark, Boolean skipSecurityCheck)
RuntimeAssembly.GetManifestResourceStream(String name, StackCrawlMark& stackMark, Boolean skipSecurityCheck)
RuntimeAssembly.GetManifestResourceStream(String name)
.Β(Assembly , String )
.ΒΒΒ(String , Assembly )
.Β(String , Assembly , Boolean )
.Β(String , Assembly )
License.SetLicense(String licenseName)
PdfGeneratorUnitTests.SetUp() line 29
Now, I was unable to find any good solutions for this issue on the internet other than upgrading Aspose product versions.
I am trying to get unit tests working with Aspose.Pdf version 9.4.0.0
Is this version of Aspose.Pdf simply too old to be used in an MSTest context? I have tried with the latest Aspose.Pdf version (23.9.0.0), which has worked.
It would be really helpful to know, whether Aspose.Pdf 9.4.0.0 methods can be used in unit testing.
Thanks for your help in advance!