public void Create(IScriptHost host)
        {
            try
            {
                m_scriptHost = host;

                m_appDomain = AppDomain.CreateDomain($"ScriptDomain_{m_instanceId}");
                m_appDomain.SetupInformation.ConfigurationFile = "dummy.config";

                m_intManager = (InternalManager)m_appDomain.CreateInstanceAndUnwrap(typeof(InternalManager).Assembly.FullName, typeof(InternalManager).FullName);

                // TODO: figure out a cleaner solution to Mono JIT corruption so server doesn't have to be slower
#if IS_FXSERVER
                m_intManager.SetScriptHost(new WrapScriptHost(host), m_instanceId);
#else
                m_intManager.SetScriptHost(Marshal.GetIUnknownForObject(host), m_instanceId);
#endif
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());

                if (e.InnerException != null)
                {
                    Debug.WriteLine(e.InnerException.ToString());
                }

                throw;
            }
        }
示例#2
0
        public void Create(IScriptHost host)
        {
            try
            {
                m_scriptHost = host;

                ((IScriptHostWithResourceData)host).GetResourceName(out var nameString);
                string resourceName = Marshal.PtrToStringAnsi(nameString);

                bool useTaskScheduler = true;

#if IS_FXSERVER
                string basePath = "";

                {
                    // we can't invoke natives if not doing this
                    InternalManager.ScriptHost = host;

                    basePath         = Native.API.GetResourcePath(resourceName);
                    useTaskScheduler = Native.API.GetNumResourceMetadata(resourceName, "clr_disable_task_scheduler") == 0;
                }
#endif

                m_appDomain = AppDomain.CreateDomain($"ScriptDomain_{m_instanceId}", AppDomain.CurrentDomain.Evidence, new AppDomainSetup()
                {
#if IS_FXSERVER
                    ApplicationBase = basePath
#endif
                });

                m_appDomain.SetupInformation.ConfigurationFile = "dummy.config";

                m_intManager = (InternalManager)m_appDomain.CreateInstanceAndUnwrap(typeof(InternalManager).Assembly.FullName, typeof(InternalManager).FullName);

                if (useTaskScheduler)
                {
                    m_intManager.CreateTaskScheduler();
                }

                m_intManager.SetResourceName(resourceName);

                // TODO: figure out a cleaner solution to Mono JIT corruption so server doesn't have to be slower
#if IS_FXSERVER
                m_intManager.SetScriptHost(new WrapScriptHost(host), m_instanceId);
#else
                m_intManager.SetScriptHost(Marshal.GetIUnknownForObject(host), m_instanceId);
#endif
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());

                if (e.InnerException != null)
                {
                    Debug.WriteLine(e.InnerException.ToString());
                }

                throw;
            }
        }
示例#3
0
        public void Create(IScriptHost host)
        {
            try
            {
                m_scriptHost = host;

#if IS_FXSERVER
                string resourceName = "";
                string basePath     = "";

                {
                    ((IScriptHostWithResourceData)host).GetResourceName(out var nameString);

                    resourceName = Marshal.PtrToStringAnsi(nameString);

                    // we can't invoke natives if not doing this
                    InternalManager.ScriptHost = host;

                    basePath = Native.API.GetResourcePath(resourceName);
                }

                // Load required assemblies by resource
                ms_appDomain.AssemblyResolve += (sender, args) =>
                {
                    var assemblyPath = Path.Combine(basePath, new AssemblyName(args.Name).Name + ".dll");
                    if (!File.Exists(assemblyPath))
                    {
                        return(null);
                    }

                    return(Assembly.LoadFile(assemblyPath));
                };
#endif

                m_intManager = (InternalManager)ms_appDomain.CreateInstanceAndUnwrap(
                    typeof(InternalManager).Assembly.FullName, typeof(InternalManager).FullName);

                // TODO: figure out a cleaner solution to Mono JIT corruption so server doesn't have to be slower
#if IS_FXSERVER
                m_intManager.SetScriptHost(new WrapScriptHost(host), m_instanceId);
#else
                m_intManager.SetScriptHost(Marshal.GetIUnknownForObject(host), m_instanceId);
#endif
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());

                if (e.InnerException != null)
                {
                    Debug.WriteLine(e.InnerException.ToString());
                }

                throw;
            }
        }
示例#4
0
        public void Create(IScriptHost host)
        {
            try
            {
                m_scriptHost = host;

                m_appDomain = AppDomain.CreateDomain($"ScriptDomain_{m_instanceId}");

                m_intManager = (InternalManager)m_appDomain.CreateInstanceAndUnwrap(typeof(InternalManager).Assembly.FullName, typeof(InternalManager).FullName);
                m_intManager.SetScriptHost(Marshal.GetIUnknownForObject(host), m_instanceId);
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());

                if (e.InnerException != null)
                {
                    Debug.WriteLine(e.InnerException.ToString());
                }

                throw;
            }
        }