Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
See original GitHub issueDescribe the bug
- System.IO.FileLoadException occurred . The detail error message is below.
Exception: System.SystemException
Message: Failed to create AppDomain.
StackTrace: at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
at System.Web.Hosting.ApplicationManager.GetAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
at System.Web.Hosting.ApplicationManager.CreateObjectInternal(String appId, Type type, IApplicationHost appHost, Boolean failIfExists, HostingEnvironmentParameters hostingParameters)
at System.Web.Hosting.ProcessHost.StartApplication(String appId, String appPath, Object& runtimeInterface)
InnerException: System.IO.FileLoadException
Message: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
StackTrace: at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(String assemblyString, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.CreateInstance(String assemblyName, String typeName)
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
at System.AppDomain.CreateAppDomainManager()
at System.AppDomain.Setup(Object arg)
at System.AppDomain.nCreateDomain(String friendlyName, AppDomainSetup setup, Evidence providedSecurityInfo, Evidence creatorsSecurityInfo, IntPtr parentSecurityDescriptor)
at System.AppDomain.InternalCreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info)
at System.AppDomain.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info)
at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
To Reproduce
- install
datadog-dotnet-apm-1.6.1-x64.msi
- exec
iisreset
- access the application.
Runtime environment (please complete the following information):
- Instrumentation mode: automatic with msi installer
- 1.6.1
- OS: Windows Server 2016 R2
- CLR: NET Framework 4.7.2 / ASP.NET WebForms Application
Additional context
- I run 4 asp.net application in a website. 3 apps are nested. And only one app is failed to start by this error.
─ App1 (asp.net webforms) ok
├─App2(asp.net mvc) ok
├─App3(asp.net webapi) ok
└─App4(asp.net webforms) System.IO.FileLoadException occurred!!
- What kind of situations is this exception happen?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
"Loading this assembly would produce a different grant set ...
Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401 (SECURITY_E_INCOMPATIBLE_SHARE)) ...
Read more >Loading this assembly would produce a different grant set ...
I ran into the same exception when developing on Sitecore, and an iisreset cleared the issue.
Read more >What does the error "Loading this assembly would produce a ...
This error indicates that the Temporary ASP.NET Files on the Document server contain incorrect information and need to be cleared. This can happen...
Read more >"Loading this assembly would produce a different grant set ...
Exception type: FileLoadException Exception message: Loading this assembly would produce a different grant set from other instances.
Read more >Loading this assembly would produce a different grant set ...
Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401).
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks, @prahutomo. Here is some documentation on the valid values for that setting.
Please keep in mind that forcing the loader optimization value to 1 (
SingleDomain
) is a workaround. The drawback is that multiple AppDomains in the same process will no longer be able share resources. For users with many applications running in the same IIS Application Pool, this setting can increase CPU and memory usage. Please use with caution!Btw, we are actively working (https://github.com/DataDog/dd-trace-dotnet/pull/505) on loading our tracer assemblies in a different way that doesn’t interfere with the ability to share assemblies between AppDomains. This should eliminate the error without the need for this workaround.
We’ve done several changes over the last few months to alleviate this issue, if not solve it completely. There is also the workaround of changing the
LoaderOptimization
setting mentioned above.We are closing this issue. Please re-open or create a new github issue if you encounter this again. Thanks.