I have a helper assembly dll developmed using C# which i invoke from my web application during a transaction.
I need my web application to be full trust and wanted to enable legacyCasModel in it, so i have added the following lines in the web.config of the application
<trust level="Full" legacyCasModel="true" />
The C# dll was loading from GAC without any issues and i was able to call the function of the assembly till the time i have added this trust tag in the web.config.
After the addition of legacyCasModel="true", the request to the web app is getting failed and there was an exception thrown in the event logs as
Failed to initialize the AppDomain:/LM/W3SVC/2/ROOT
Exception: System.IO.FileLoadException
Message: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
StackTrace: at System.Web.Configuration.HttpConfigurationSystem.EnsureInit(IConfigMapPath configMapPath, Boolean listenToFileChanges, Boolean initComplete)
at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel) at System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel) at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters) at System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(String appId, IApplicationHost appHost, HostingEnvironmentParameters hostingParameters)
If i comment out the function bodies in the assembly and just return;
the control, the exception is not occuring. If any of the functions in the assembly have .Net Framework classes like System.Web.HttpContext then the exception gets thrown.
How can i resolve this error without disabling legacyCasModel? Should i implement any security attributes to my assembly ?
Note: My assembly is installed in GAC with AnyCPU, .Net 3.5 compiled. It is digitally signed with digicert but does not have x509Certificate in the evidence(does it matters?? )
User contributions licensed under CC BY-SA 3.0