Failure details: System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port)
at com.altaworks.da.DsaPortRequestor.getPortUsingSocket(String hostName, Int32 httpPort)
This problem seems to match another blog posting on the Microsoft Forums and in that case a profiler was in the picture as well. The suggestion there was to turn off legacy code access security. Turning off legacy code access security ("LegacyCASModel=false") will fix the issue but that is not an acceptable solution.
The application profiled is a SharePoint 2013 application. Through IL rewriting the profiler is adding an assembly reference to an external helper assembly that is associated with the unmanaged profiler. That assembly is being loaded into the shared app domain apparently with Full Trust and in a Security Transparent manner. The problem was reproduced on Windows 7 but was first reported on W2k12-R1 and W2K12-R2.
The helper assembly is attempting to send profiling data collected to another process.
Security Rule Set: Level1
Is Fully Trusted: True
Zone Evidence: MyComputer
Security Critical: False
Security SafeCritical: False
Security Transparent: True
Operating System: Windows 7 (Microsoft Windows NT 6.2.9200.0)
OS Version: 6.2.9200.0
.NET Version: 4.0.30319.18046
CLR running in: 64 bit mode