5

I have deployed my .NET instrumentation profiler into Azure webapps through Visual studio 2012. My profiler does byte code instrumentation which looks like below,

FunctionA()
{
   --> Injected C# function Call 
   functionA's body
   -->Injected C# function Call
}

The injected function call resides on a separate assembly dll. In a physical box the assembly will be added in GAC. But in Azure it will be present in a folder in web app location which will be probed in web.config file.

Using DefineAssemblyRef of IMetaDataAssemblyEmit, i define the assembly and it's function in each modules that loads into the process. The issue is the injected function call works only for the functions of the web application modules..! Other modules like System.Web.dll or System.Data.dll is failing to call the function, which makes the Azure web app failed to load with 502 error.

Shortly, injecting into modules other than the web application is getting failed. I guess it to be security issue in loading the custom assembly and I tried setting [assembly: System.Security.AllowPartiallyTrustedCallers] and PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")] and some other security attributes too.. none helped.. How to make this helper assembly to load by the .Net modules.? Is there any other specific security attributes i need to set for the assembly in-order to get loaded..?

valiano
  • 16,433
  • 7
  • 64
  • 79
Sel_va
  • 588
  • 5
  • 25
  • I don't know enough about azure, but you may get a hint if you can enable a FusionLog (or an azure equivalent). You could also try to use the [AppDomain.AssemblyResolve](https://msdn.microsoft.com/en-us/library/system.appdomain.assemblyresolve.aspx) event to manually load the assembly. I don't know enough about Azure, but I can imagine that it may be doing some nGen-preprocessor magic. – Louis Somers Jul 09 '18 at 11:39
  • Don't you encounter the same issue locally when instrumenting an IIS process? I suspect the helper assembly is not initially in the probing path while System assemblies get loaded, but it gets there once IIS fully loads your website and reads your web.config. – Claudiu Guiman Feb 19 '19 at 21:16

0 Answers0