The SharePoint Site Page displays “500 – Internal Server Error” while accessing it after the successful SharePoint 2013 farm setup. The event viewer shows:
“.NET Runtime version 4.0.30319.18408 – The profiler was loaded successfully. Profiler CLSID: ‘AppDynamics.AgentProfiler’. Process ID (decimal): 13688. Message ID: [0x2507].”
From SharePoints Claims Authentication:
“An exception occurred when trying to issue security token: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401).”
By default SP2013 uses the legacy code access security model which is less configurable than the latest 4.0 model. Normally, .NET runtime security system walks the call stack to determine the code is authorized to access a resource or perform an operation, comparing the granted permissions of each caller to the permission being demanded. If any caller in the call stack does not have the demanded permission, a security exception is thrown and access refused.
Below is the small illustration of Security stack walk: (Courtesy: MSDN article on Code Access Security)
As you’ve noticed in the Event Viewer, .NET Runtime throws that the profiler isn’t compatible with the legacy model. To resolve the issue, please update your web application or problematic web app’s web.config by setting legacyCasModel attribute to false as shown in below.
<trust level=”Full” originUrl=”” legacyCasModel=”false” />