Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

Running Profiler inside certain IIS ASP.NET 4.0 apps results in error (Exception from HRESULT: 0x80131401)

$
0
0

I have a IL rewriting profiler which uses the profiling API to intercept JITs and writes prologue\epilogues calling a supporting C# assembly(HP.Diagnostics).

We have been running our product(HP Diagnostics)successfully in many customer environments with success but have recently observed the following problem.

The supporting C# Profiler Assembly(HP.Diagnostics gets the following error when running in certain IIS hosted ASP.NET (.NET 4.0) applications on Windows 2008 R2.

   System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)

The supporting profiler DLL(HP.Diagnostics) is installed and loaded from GAC and should have full trust.

The Profiler logs show that the supporting C# Assembly(HP.Diagnostics) is loaded in multiple application domains, first in the Appdomain of the IIS application and then the "EE Shared Assembly Repository". This seems to be the cause of the problem.

The logs below are generated by the ICorProfilerCallback::AssemblyLoadFinished callback.

2013.02.14.14.48.57.295  [000019C4]  INFO     AssemblyLoadFinished hrStatus(00000000) appDomainId(067CC730) appDomainName(/LM/W3SVC/2/ROOT-1-130053449274613565) assemblyId(06A87D00) assemblyName(HP.Diagnostics)
2013.02.14.14.48.57.310  [000019C4]  INFO     AssemblyLoadFinished hrStatus(00000000) appDomainId(FA2862B0) appDomainName(EE Shared Assembly Repository) assemblyId(06A87EC0) assemblyName(HP.Diagnostics)

How can we work around this problem ? Is there a fix for this issue ?

In certain IIS applications, e.g. SharePoint 2013, the behavior can be altered by changing the "trust" setting as shown below in the web.config file.

<trust level="Full" originUrl="" legacyCasModel="false" />

    <!--<trust level="Full" originUrl="" legacyCasModel="true" />-->

This does not work for all applications so we have no work around in certain scenarios.

Can somebody explain why changing the legacyCasModel="false"  changes the way the assemblies are loaded in different appdomains ?

Regards,

Sanjay


Sanjay Mehta


Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>