Hi, I'm testing a byte-code rewriting profiler that would prefix some methods with a call into an empty class/stub in an external GAC-ed assembly. This profiler fails quickly in ASP.NET when it modifies methods inside mscorlib. In this case, I'm modifying only overloaded constructors for System.Collections.Queue. The prefixed call is done by creating an assemblyRef/typeRef/memberRef to the external assembly. The external assembly has been reduced to a single class with only static/void/empty methods. This also means the external assembly has no additional dependencies. The exception occurs during AppDomain construction. Is implicitly loading of external assemblies prohibited at particular points in the CLR/AppDomain loading process? If not, what is the problem here? The profiler works great for classes NOT in mscorlibs. The Event Viewer shows an internally caught System.ExecutionEngineException. CLR exception
Exception object: 180a451c
Exception type: System.IO.FileLoadException
Message: Could not load file or assembly 'my.external, Version=1.0.0.0, Culture=neutral, PublicKeyToken=somepublickey' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
InnerException: <none>
StackTrace (generated):
<none>
StackTraceString: <none>
HResult: 80070057
The CLR stack
OS Thread Id: 0x2a6c (17)
ESP EIP
0279d4a0 7d61002d [GCFrame: 0279d4a0]
0279d52c 7d61002d [GCFrame: 0279d52c]
0279e50c 7d61002d [PrestubMethodFrame: 0279e50c] System.Collections.Queue..ctor()
0279e51c 04549606 System.Runtime.Remoting.RemotingConfigHandler..cctor()
0279e8b0 79e7c74b [GCFrame: 0279e8b0]
0279ee18 79e7c74b [PrestubMethodFrame: 0279ee18] System.Runtime.Remoting.RemotingConfigHandler.get_UrlObjRefMode()
0279ee28 045495a6 System.Runtime.Remoting.ObjRef.ShouldUseUrlObjRef()
0279ee2c 04545555 System.Runtime.Remoting.ObjRef.Init(System.Object, System.Runtime.Remoting.Identity, System.Type)
0279ee5c 0454534c System.Runtime.Remoting.ObjRef..ctor(System.MarshalByRefObject, System.Type)
0279ee70 0454528c System.MarshalByRefObject.CreateObjRef(System.Type)
0279ee80 045436f1 System.Runtime.Remoting.RemotingServices.MarshalInternal(System.MarshalByRefObject, System.String, System.Type, Boolean)
0279eed4 04543531 System.Runtime.Remoting.RemotingServices.CreateDataForDomainCallback(System.Object[])
0279eee0 045434e8 System.Threading.Thread.CompleteCrossContextCallback(System.Threading.InternalCrossContextDelegate, System.Object[])
0279f0dc 79e7c74b [ContextTransitionFrame: 0279f0dc]
0279f0a4 79e7c74b [HelperMethodFrame_PROTECTOBJ: 0279f0a4] System.Threading.Thread.InternalCrossContextCallback(System.Runtime.Remoting.Contexts.Context, IntPtr, Int32, System.Threading.InternalCrossContextDelegate, System.Object[])
0279f1ac 04541232 System.Runtime.Remoting.RemotingServices.CreateDataForDomain(Int32, IntPtr)
0279f1bc 0454119f System.Runtime.Remoting.RemotingServices.CreateProxyForDomain(Int32, IntPtr)
0279f48c 79f5e350 [HelperMethodFrame_PROTECTOBJ: 0279f48c] System.AppDomain.nCreateDomain(System.String, System.AppDomainSetup, System.Security.Policy.Evidence, System.Security.Policy.Evidence, IntPtr)
0279f500 03fcd197 System.AppDomain.CreateDomain(System.String, System.Security.Policy.Evidence, System.AppDomainSetup)
0279f51c 03fca55e System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironment(System.String, System.Web.Hosting.IApplicationHost, System.Web.Hosting.HostingEnvironmentParameters)
0279f59c 03fca38f System.Web.Hosting.ApplicationManager.CreateAppDomainWithHostingEnvironmentAndReportErrors(System.String, System.Web.Hosting.IApplicationHost, System.Web.Hosting.HostingEnvironmentParameters)
0279f5d8 03fca20c System.Web.Hosting.ApplicationManager.GetAppDomainWithHostingEnvironment(System.String, System.Web.Hosting.IApplicationHost, System.Web.Hosting.HostingEnvironmentParameters)
0279f628 03fca036 System.Web.Hosting.ApplicationManager.CreateObjectInternal(System.String, System.Type, System.Web.Hosting.IApplicationHost, Boolean, System.Web.Hosting.HostingEnvironmentParameters)
0279f648 030fdd7f System.Web.Hosting.AppManagerAppDomainFactory.Create(System.String, System.String)
0279f898 79f047fd [GCFrame: 0279f898]
0279f9f4 79f047fd [ComMethodFrame: 0279f9f4]
Native stack
ChildEBP RetAddr
0279cf24 7a1060b3 ntdll!DbgBreakPoint
0279d3d4 7a10624f mscorwks!EEPolicy::LogFatalError+0x2b5
0279d3ec 79f071c7 mscorwks!EEPolicy::HandleFatalError+0x36
0279d44c 7a10733d mscorwks!RaiseTheExceptionInternalOnly+0x2c3
0279d464 7a1073b1 mscorwks!RaiseTheException+0x4e
0279d48c 7a1073e2 mscorwks!RaiseTheException+0xc0
0279d4b8 7a1073f0 mscorwks!RealCOMPlusThrow+0x30
0279d4c8 7a010c38 mscorwks!RealCOMPlusThrow+0xd
0279d5b8 79f112e4 mscorwks!CEEInfo::findMethodInternal+0x3ae
0279d638 79061fd6 mscorwks!CEEInfo::findMethod+0x107
0279d650 7906535a mscorjit!Compiler::eeFindMethod+0x22
0279d720 79063324 mscorjit!Compiler::impImportCall+0xa7
0279dcf8 790635c3 mscorjit!Compiler::impImportBlockCode+0x29ae
0279dd7c 7906355b mscorjit!Compiler::impImportBlock+0x20c
0279dd94 79063494 mscorjit!Compiler::impImport+0xe5
0279dda0 79064e1c mscorjit!Compiler::fgImport+0x20
0279ddac 790614e6 mscorjit!Compiler::compCompile+0xb
0279de04 79061236 mscorjit!Compiler::compCompile+0x2df
0279de98 7906118c mscorjit!jitNativeCode+0xb8
0279ded0 79f0f9cf mscorjit!CILJit::compileMethod+0x3d
|