ejecting code sharing because a dependent assembly did not match the conditional APTCA share mode

Oct 5, 2015 at 5:02 PM
Hi. I have a problem with SharePoint 2013 and profiling using rewritten IL very similar to this issue:

https://social.msdn.microsoft.com/Forums/office/en-US/3579663c-da2f-48ca-82ed-469be039c7d2/running-profiler-inside-certain-iis-aspnet-40-apps-results-in-error-exception-from-hresult?forum=clr

In my case, I had instrumented several System.Net.Sockets.Socket methods, but when the profiled code gets invoked and executes into my profiling agent, the event log shows entries like so:
An unhandled exception occurred and the process was terminated.

Application ID: /LM/W3SVC/1551841460/ROOT

Process ID: 10036

Exception: System.IO.FileLoadException

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

StackTrace: 
Server stack trace: 
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
Any recommendations or thoughts?