public GlobalAIProxy DynLoad( string assemblyfilename, string debugfilename, string targettypename, string methodname ) { WriteLine( "reading assembly [" + assemblyfilename + "]..." ); assemblybytes = ReadFile( assemblyfilename ); WriteLine( "... assembly read" ); IGlobalAI iglobalaiobject = getResult( assemblybytes, targettypename, methodname ) as IGlobalAI; GlobalAIProxy globalaiproxy = new GlobalAIProxy( iglobalaiobject ); return globalaiproxy; }
// DynLoadInAppDomain loads the AI dll in a separate appdomain, one per AI // This is absolutely lagtastic. So dont do that. CSharpAI.GlobalAIProxy DynLoadInAppDomain(string dllpath, string classname, string methodname) { appdomainname = "csai" + nextappdomainref; nextappdomainref++; WriteLine("appdomain name: " + appdomainname); //Evidence baseEvidence = AppDomain.CurrentDomain.Evidence; //WriteLine( "got base evidence" ); //Evidence evidence = new Evidence(baseEvidence); Evidence evidence = new Evidence(); WriteLine("created new evidence"); ourappdomain = AppDomain.CreateDomain(appdomainname, evidence); WriteLine("domain created"); IMonoLoaderProxy monoloaderproxy = ourappdomain.CreateInstanceAndUnwrap("MonoLoaderProxy, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "CSharpAI.MonoLoaderProxy") as IMonoLoaderProxy; WriteLine("got monoloaderproxy"); GlobalAIProxy globalaiproxy = monoloaderproxy.DynLoad(dllpath, "", classname, methodname); WriteLine("back from dynload"); return(globalaiproxy); }