public static void executeInAppDomain(string appDomainName,string scriptToExecute)
		{
				O2Thread.mtaThread(
					()=>{
							var o2AppDomain =  new O2AppDomainFactory(appDomainName);
							try
							{
								o2AppDomain.load("O2_XRules_Database"); 	
								o2AppDomain.load("O2_Kernel");
								o2AppDomain.load("O2_DotNetWrappers");
							
								var o2Proxy =  (O2Proxy)o2AppDomain.getProxyObject("O2Proxy");
								 
								o2Proxy.InvokeInStaThread = true;
								o2Proxy.staticInvocation("O2_External_SharpDevelop","FastCompiler_ExtensionMethods","executeSourceCode",new object[]{ scriptToExecute });								
							}
							catch(Exception ex)
							{
								ex.log("inside new AppDomain"); 
							}
							
							DebugMsg.showMessageBox("Click OK to close the '{0}' AppDomain (and close all open windows)".format(appDomainName));							
							o2AppDomain.unLoadAppDomain();
						});
		  }
Example #2
0
        public static string codeStreams_CreateInAppDomain(this Saved_MethodStream savedMethodStream)
        {
            //var script = @"C:\O2\_XRules_Local\Ast_Test.cs";
            var script = "Saved_MethodStream.cs".local();
            "Creating new AppDomain".info();
            var appDomainName = 4.randomString();
            var o2AppDomain =  new O2AppDomainFactory(appDomainName);
            o2AppDomain.load("FluentSharp.CoreLib.dll");
            var o2Proxy =  (O2Proxy)o2AppDomain.getProxyObject("O2Proxy");
            var parameters = new object[]
                    {
                        savedMethodStream.Serialized_Saved_MethodStream_FileCache
            //						sourceFolder,
            //						resultsFolder,
            //						methodFilter,
            //						useCachedData,
            //						references,
            //						numberOfItemsToProcess
                    };

            var result =(string)o2Proxy.staticInvocation("O2_External_SharpDevelop","FastCompiler_ExtensionMethods","executeFirstMethod",new object[]{script, parameters});
            "Result: {0}".info(result);
            o2AppDomain.sleep(2000);
            o2AppDomain.unLoadAppDomain();
            "AppDomain execution completed, Runing GCCollect".info();
            PublicDI.config.gcCollect();
            "GCCollect completed, returning result data: {0}".info(result);
            return result;
        }
    public static O2AppDomainFactory getO2AppDomainFactoryOnTempDirWithAllDependenciesResolved(
        string fullPathToDllToProcess)
    {
        var o2AppDomainFactory = new O2AppDomainFactory();
        if (false ==
            o2AppDomainFactory.load(Path.GetFileNameWithoutExtension(fullPathToDllToProcess), fullPathToDllToProcess,
                                    true))
            return null;
        Dictionary<string, string> assemblyDependencies =
            new CecilAssemblyDependencies(fullPathToDllToProcess).calculateDependencies();
 
        if (o2AppDomainFactory.load(assemblyDependencies).Count == 0)
            return o2AppDomainFactory;
        PublicDI.log.error(
            "in getO2AppDomainFactoryOnTempDirWithAllDependenciesResolved, there were assemblyDependencies that were not loaded, for: " +
            fullPathToDllToProcess);
        return null;
    }
        public static string executeEngineOnSeparateAppDomain(string sourceFolder, string resultsFolder, string methodFilter, bool useCachedData, List<string> references, int numberOfItemsToProcess)
        {
            //var script = @"C:\O2\_XRules_Local\Ast_Test.cs";
            var script = "MethodMappings_Engine.cs".local();
            "Creating new AppDomain".info();
             			var appDomainName = 4.randomString();
            var o2AppDomain =  new O2AppDomainFactory(appDomainName);
            //o2AppDomain.load("O2_XRules_Database");
            //o2AppDomain.load("O2_Kernel");
            //o2AppDomain.load("O2_DotNetWrappers");
            o2AppDomain.load("FluentSharp.CoreLib");
            o2AppDomain.load("FluentSharp.WinForms");
            o2AppDomain.load("FluentSharp.REPL");
            o2AppDomain.load("FluentSharp.SharpDevelopEditor.dll");
            var o2Proxy =  (O2Proxy)o2AppDomain.getProxyObject("O2Proxy");
            var parameters = new object[]
                    {
                        sourceFolder,
                        resultsFolder,
                        methodFilter,
                        useCachedData,
                        references,
                        numberOfItemsToProcess
                    };

            var result =(string)o2Proxy.staticInvocation("O2_External_SharpDevelop","FastCompiler_ExtensionMethods","executeFirstMethod",new object[]{script, parameters});
            o2AppDomain.unLoadAppDomain();
            "AppDomain execution completed, Runing GCCollect".info();
            PublicDI.config.gcCollect();
            "GCCollect completed, returning result data: {0}".info(result);
            return result;
        }