I am working on instrumenting .NET web applications using IL rewriting. My profiler injects code into each and every functions and tracks it.
The injected code is a function call that resides in a helper assembly which will be present in the GAC. This works perfectly in all the web applications, the problem comes with Sharepoint machine.
Instrumenting the functions of .NET Framework modules in Sharepoint machine and making them to call the functions that resides in the helper assembly fails with the error below,
This makes the w3wp of the sharepoint app to crash. But on changing the legacycasmodel to false in the web.config file of the sharepoint application or by adding LoaderOptimization DWORD with 1 solves the problem.
I should not go in that way as it is not advisable by Microsoft. I tried adding some security attributes in AssemblyInfo.cs and added permissionsets to the methods of my helperassembly that will be in GAC (as below) . But none helped solving the crash.
[SecuritySafeCritical] [PermissionSet(SecurityAction.Assert, Name = "Execution")] public static void Func1(int s, int s1, int s2) { }
What only is stopping to call the function of my helper assembly in Sharepoint application alone.? How should i resolve this without LoaderOptimization or disabling legacycasmodel ??