ASP.Net Exception after upgrading to .Net 4.0 with impersonation

We have a running application on .Net 3.5 which we are attempting to upgrade to .Net 4.0.

We are using impersonation in the web.config file like so:

<identity impersonate="true" userName="domain\user" password="pwd"/>

With impersonation turned on, we get this exception noted below. Please assist. We are using Aspose.Pdf version 4.6.0.0 on ASP.Net 4.0. My development machine (where the exception is occuring) is Windows 7 64 bit. All the libraries are being compiled on 'AnyCPU' platform.

There is no exception when I take the impersonation off.

----------------------------------------------------------------

Could not load file or assembly 'Aspose.Pdf' or one of its dependencies. An API call exited abnormally. (Exception from HRESULT: 0x800300FA (STG_E_ABNORMALAPIEXIT))

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Aspose.Pdf' or one of its dependencies. An API call exited abnormally. (Exception from HRESULT: 0x800300FA (STG_E_ABNORMALAPIEXIT))

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'Aspose.Pdf' could not be loaded.

=== Pre-bind state information ===
LOG: User = Unknown
LOG: DisplayName = Aspose.Pdf
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: Aspose.Pdf | Domain ID: 2
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:/TFS/ReliusSSO/Web/
LOG: Initial PrivatePath = C:\TFS\ReliusSSO\Web\bin
Calling assembly : (Unknown).
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\TFS\ReliusSSO\Web\web.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\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:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/a51b73b5/dcc56846/Aspose.Pdf.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/a51b73b5/dcc56846/Aspose.Pdf/Aspose.Pdf.DLL.
LOG: Attempting download of new URL file:///C:/TFS/ReliusSSO/Web/bin/Aspose.Pdf.DLL.
LOG: Using application configuration file: C:\TFS\ReliusSSO\Web\web.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Aspose.Pdf, Version=4.6.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56
ERR: Failed to complete setup of assembly (hr = 0x800300fa). Probing terminated.

Stack Trace:

[FileLoadException: Could not load file or assembly 'Aspose.Pdf' or one of its dependencies. An API call exited abnormally. (Exception from HRESULT: 0x800300FA (STG_E_ABNORMALAPIEXIT))]

[FileLoadException: Could not load file or assembly ‘Aspose.Pdf, Version=4.6.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. An API call exited abnormally. (Exception from HRESULT: 0x800300FA (STG_E_ABNORMALAPIEXIT))]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +39
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +132
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +144
System.Reflection.Assembly.Load(String assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46

[ConfigurationErrorsException: Could not load file or assembly ‘Aspose.Pdf, Version=4.6.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. An API call exited abnormally. (Exception from HRESULT: 0x800300FA (STG_E_ABNORMALAPIEXIT))]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +618
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +209
System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
System.Web.Compilation.BuildProvidersCompiler…ctor(VirtualPath configPath, Boolean supportLocalization, String outputAssemblyName) +45
System.Web.Compilation.CodeDirectoryCompiler.GetCodeDirectoryAssembly(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories, Boolean isDirectoryAllowed) +8776683
System.Web.Compilation.BuildManager.CompileCodeDirectory(VirtualPath virtualDir, CodeDirectoryType dirType, String assemblyName, StringSet excludedSubdirectories) +125
System.Web.Compilation.BuildManager.CompileCodeDirectories() +387
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +248

[HttpException (0x80004005): Could not load file or assembly ‘Aspose.Pdf, Version=4.6.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. An API call exited abnormally. (Exception from HRESULT: 0x800300FA (STG_E_ABNORMALAPIEXIT))]
System.Web.Compilation.BuildManager.ReportTopLevelCompilationException() +62
System.Web.Compilation.BuildManager.EnsureTopLevelFilesCompiled() +421
System.Web.Compilation.BuildManager.CallAppInitializeMethod() +31
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +605

[HttpException (0x80004005): Could not load file or assembly ‘Aspose.Pdf, Version=4.6.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. An API call exited abnormally. (Exception from HRESULT: 0x800300FA (STG_E_ABNORMALAPIEXIT))]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +8946484
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +97
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +258

Hello Arvinder,

Thanks for using our products.

We are working over this query and will get back to you soon. We apologize for your inconvenience.

Has this issue been resolved? We are experiencing the same error.

Hi,

Thanks for using our products.

I am pleased to inform you that the problem seems to be resolved in latest release version of Aspose.Pdf for .NET 5.1.0 (available for download over this link). During my testing in a simple web application, I am unable to notice this problem. Please try using this version and in case you still encounter this problem or you have any further query, please feel free to contact. We apologize for your inconvenience.