Profiler Assembly gets the following error when running in SharePoint Server2013 (.NET 4.0) on Windows 2008 R2.
System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
at System.Net.HttpWebRequest.GetRequestStream()
The profiler DLL is loaded from GAC and should have full trust.
Changing the default SharePoint site Web.config as shown below works around this problem
<trust level="Full" originUrl="" legacyCasModel="false" />
<!--<trust level="Full" originUrl="" legacyCasModel="true" />-->
This feels like a bug in the Microsoft APIs (CAS), can anybody verify this is a problem ? and whether there is a fix for this.
It looks very much like a the problem found in .NET 2.0 http://blogs.msdn.com/b/jaskis/archive/2010/01/05/intermittently-getting-loading-this-assembly-would-produce-a-different-grant-set-from-other-instances-exception-from-hresult-0x80131401-after-net-3-5-sp-1.aspx
Regards,
Sanjay
Sanjay Mehta