AppDomain.CreateInstanceAndUnwrap throws an exception FileLoadException with STG_E_ABNORMALAPIEXIT on Windows 2k3

0

In ASP.NET application I'm trying to execute method in AppDomain from different assembly stored in bin subfolder. I'm creating AppDomain and calling AppDomain.CreateInstanceAndUnwrap. It works fine on my computer and Windows Server 2K8 but on Windows Server 2k3 throws an exception:

at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName) at System.AppDomain.CreateInstance(String assemblyName, String typeName) at System.Activator.CreateInstance(String assemblyName, String typeName) at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark) at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)

System.IO.FileLoadException: Could not load file or assembly 'MyAssembly' or one of its dependencies. An API call exited abnormally. (Exception from HRESULT: 0x800300FA (STG_E_ABNORMALAPIEXIT)) System.IO.FileLoadException: Could not load file or assembly 'MyAssembly, Version=2.23.7.23064, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An API call exited abnormally. (Exception from HRESULT: 0x800300FA (STG_E_ABNORMALAPIEXIT))

Does somebody have an idea why?

c#
asp.net
reflection
asked on Stack Overflow Aug 14, 2012 by Dmitry Borovsky • edited Aug 14, 2012 by Dmitry Borovsky

1 Answer

0

My answer (AppDomain shadow copied file access denied with ASP.NET site running on IIS6): The reason of the problem is CachePath default value. If an AppPool is run under network service, DefaultUser temp folder location is used (I don't know why). But Network Service doesn't have access to the folder and it's the reason of the exception. The solution is to set CachePath explicitly. For example, we can use ASP.NET AppPool cache path:

var domainInfo = new AppDomainSetup
  {
    CachePath = AppDomain.CurrentDomain.SetupInformation.CachePath
    /* ...*/
  };
answered on Stack Overflow Aug 21, 2012 by Dmitry Borovsky • edited May 23, 2017 by Community

User contributions licensed under CC BY-SA 3.0