示例#1
0
        public SS14UnitTest()
        {
            /*
             * Assembly.getEntryAssembly() returns null because Unit tests
             * are unmanaged and have no app domain managers.
             * this causes IOCManager to never load or build any of the types
             *
             * Fixed by Setting the Entry assembly values manually here
             */
            Assembly assembly = Assembly.GetCallingAssembly();

            AppDomainManager manager            = new AppDomainManager();
            FieldInfo        entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);

            entryAssemblyfield.SetValue(manager, assembly);

            AppDomain domain             = AppDomain.CurrentDomain;
            FieldInfo domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);

            domainManagerField.SetValue(domain, manager);

            /* end fix */


            //ConfigurationManager setup
            GetConfigurationManager = IoCManager.Resolve <IPlayerConfigurationManager>();
            GetConfigurationManager.Initialize("./player_config.xml");

            //ResourceManager Setup
            GetResourceManager = IoCManager.Resolve <IResourceManager>();
            InitializeResources();
        }
        public static bool DetermineApplicationTrust(ActivationContext activationContext, TrustManagerContext context)
        {
            if (activationContext == null)
            {
                throw new ArgumentNullException("activationContext");
            }

            ApplicationTrust appTrust      = null;
            AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager;

            if (domainManager != null)
            {
                HostSecurityManager securityManager = domainManager.HostSecurityManager;
                if ((securityManager != null) && ((securityManager.Flags & HostSecurityManagerOptions.HostDetermineApplicationTrust) == HostSecurityManagerOptions.HostDetermineApplicationTrust))
                {
                    appTrust = securityManager.DetermineApplicationTrust(CmsUtils.MergeApplicationEvidence(null, activationContext.Identity, activationContext, null), null, context);
                    if (appTrust == null)
                    {
                        return(false);
                    }
                    return(appTrust.IsApplicationTrustedToRun);
                }
            }

            appTrust = DetermineApplicationTrustInternal(activationContext, context);
            if (appTrust == null)
            {
                return(false);
            }
            return(appTrust.IsApplicationTrustedToRun);
        }
示例#3
0
 public static Assembly GetEntryAssembly()
 {
     AppDomainManager domainManager = AppDomain.CurrentDomain.DomainManager;
     if (domainManager == null)
         domainManager = new AppDomainManager();
     return domainManager.EntryAssembly;
 }
示例#4
0
        static void Main(string[] args)
        {
            ////创建
            //AppDomain myDomain = AppDomain.CreateDomain("MyDomainName");
            //获取此应用程序域的友好名称
            //Console.WriteLine("My Domain is :{0}",myDomain.FriendlyName);

            //Console.WriteLine("当前程序域的名称是:{0}",AppDomain.CurrentDomain.FriendlyName);

            ////卸载
            //AppDomain.Unload(myDomain);

            ////试图访问被卸载的应用程序域
            //try
            //{
            //    Console.WriteLine("My Domain is :{0}", myDomain.FriendlyName);
            //}
            //catch (CannotUnloadAppDomainException ex)
            //{

            //    throw ex;
            //}

            //获取当前应用程序域的相关信息

            //1、获取上下文
            ActivationContext tContext = AppDomain.CurrentDomain.ActivationContext;
            //2、获取应用程序标识
            ApplicationIdentity iIdentity = AppDomain.CurrentDomain.ApplicationIdentity;

            //3、获取当前应用程序的信任级别
            System.Security.Policy.ApplicationTrust tTrust = AppDomain.CurrentDomain.ApplicationTrust;
            //4、获取程序集目录 由程序集冲突解决程序来探测程序集 --静态
            string tDirectory = AppDomain.CurrentDomain.BaseDirectory;
            //动态目录
            string tDynamicDirectory = AppDomain.CurrentDomain.DynamicDirectory;
            //获取相对于基目录的路径 探测专用程序集
            string tRPath = AppDomain.CurrentDomain.RelativeSearchPath;

            //5、获取应用程序域管理器
            AppDomainManager tDomainManager = AppDomain.CurrentDomain.DomainManager;

            //6、获取此应用程序相关联的Evident 用于安全策略的输入
            System.Security.Policy.Evidence tEvidence = AppDomain.CurrentDomain.Evidence;

            //标识应用程序域中的ID
            int tID = AppDomain.CurrentDomain.Id;
            //标识应用程序是否完全信任级别
            bool blIsFullyTrust = AppDomain.CurrentDomain.IsFullyTrusted;
            //获取一个值表示是否拥有对加载当前应用程序域的所有程序集的权限集合
            bool isHomoGenous = AppDomain.CurrentDomain.IsHomogenous;
            //安装信息
            AppDomainSetup taSetup = AppDomain.CurrentDomain.SetupInformation;
            //是否影响复制
            bool tsCopyFile = AppDomain.CurrentDomain.ShadowCopyFiles;

            Console.WriteLine(taSetup);

            Console.Read();
        }
示例#5
0
        public bool IsStateAvailable()
        {
            AppDomainManager domainManager = AppDomainManager.CurrentAppDomainManager;

            // CheckSecuritySettings only when appdomainManager is present. So if there is no
            // appDomain Manager return true as by default coreclr runs in fulltrust.
            return(domainManager != null?domainManager.CheckSecuritySettings(this) : true);
        }
 public void ShowList()
 {
     Console.WriteLine("Available bikes: ");
     foreach (var bike in AppDomainManager.GetAllBikes())
     {
         Console.WriteLine("{0} - {1}, EUR {2}/h", bike.)
     }
 }
示例#7
0
 public void Array_Critical()
 {
     // exception occurs before reaching the code (JIT time) and the harness consider this a success
     Assert.IsFalse(true, "This fails before the method is executed");
     // critical type
     AppDomainManager [] adm = new AppDomainManager [0];
     Assert.IsNotNull(adm, "AppDomainManager[]");
 }
示例#8
0
        static internal Evidence GetDefaultHostEvidence(Assembly a)
        {
            Evidence e     = new Evidence();
            string   aname = a.EscapedCodeBase;

            // by default all assembly have the Zone, Url and Hash evidences
            e.AddHost(Zone.CreateFromUrl(aname));
            e.AddHost(new Url(aname));
            e.AddHost(new Hash(a));

            // non local files (e.g. http://) also get a Site evidence
            if (String.Compare("FILE://", 0, aname, 0, 7, true, CultureInfo.InvariantCulture) != 0)
            {
                e.AddHost(Site.CreateFromUrl(aname));
            }

            // strongnamed assemblies gets a StrongName evidence
            AssemblyName an = a.GetName();

            byte[] pk = an.GetPublicKey();
            if ((pk != null) && (pk.Length > 0))
            {
                StrongNamePublicKeyBlob blob = new StrongNamePublicKeyBlob(pk);
                e.AddHost(new StrongName(blob, an.Name, an.Version));
            }

            // Authenticode(r) signed assemblies get a Publisher evidence
            if (IsAuthenticodePresent(a))
            {
                try {
                    X509Certificate x509 = X509Certificate.CreateFromSignedFile(a.Location);
                    e.AddHost(new Publisher(x509));
                }
                catch (CryptographicException) {
                }
            }

            // assemblies loaded from the GAC also get a Gac evidence (new in Fx 2.0)
            if (a.GlobalAssemblyCache)
            {
                e.AddHost(new GacInstalled());
            }

            // the current HostSecurityManager may add/remove some evidence
            AppDomainManager dommgr = AppDomain.CurrentDomain.DomainManager;

            if (dommgr != null)
            {
                if ((dommgr.HostSecurityManager.Flags & HostSecurityManagerOptions.HostAssemblyEvidence) ==
                    HostSecurityManagerOptions.HostAssemblyEvidence)
                {
                    e = dommgr.HostSecurityManager.ProvideAssemblyEvidence(a, e);
                }
            }

            return(e);
        }
示例#9
0
 public void Field_SecurityCritical()
 {
     Assert.Throws <FieldAccessException> (delegate {
         Assert.IsNotNull(field, "read");                  // Assert should not be executed
     }, "read");
     Assert.Throws <FieldAccessException> (delegate {
         field = null;
     }, "write");
 }
示例#10
0
        private static Assembly GetEntryAssembly()
        {
            if (AppDomain.CurrentDomain != null && AppDomain.CurrentDomain.DomainManager != null)
            {
                return(AppDomain.CurrentDomain.DomainManager.EntryAssembly);
            }
            var ma = new AppDomainManager();

            return(ma.EntryAssembly);
        }
示例#11
0
        internal static HostExecutionContextManager GetCurrentHostExecutionContextManager()
        {
            AppDomainManager appDomainManager = AppDomainManager.CurrentAppDomainManager;

            if (appDomainManager != null)
            {
                return(appDomainManager.HostExecutionContextManager);
            }
            return((HostExecutionContextManager)null);
        }
示例#12
0
        public void MultidimentionalArrays()
        {
            // transparent type
            FrameworkElement [,] fe = new FrameworkElement [0, 0];
            Assert.IsNotNull(fe, "FrameworkElement[,]");

            // critical type
            AppDomainManager [,] adm = new AppDomainManager [0, 0];
            Assert.IsNotNull(adm, "AppDomainManager[,]");
        }
示例#13
0
        public bool IsStateAvailable()
        {
            AppDomainManager adm = AppDomain.CurrentDomain.DomainManager;

            if (adm == null)
            {
                return(false);
            }
            return(adm.CheckSecuritySettings(this));
        }
示例#14
0
        public void CheckSecuritySettings()
        {
            AppDomainManager adm = new AppDomainManager();

            Assert.IsFalse(adm.CheckSecuritySettings(null), "null");

            ContreteSecurityState ss = new ContreteSecurityState();

            Assert.IsFalse(adm.CheckSecuritySettings(ss), "ContreteSecurityState");
        }
示例#15
0
        public bool IsStateAvailable()
        {
            AppDomainManager currentAppDomainManager = AppDomainManager.CurrentAppDomainManager;

            if (currentAppDomainManager == null)
            {
                return(false);
            }
            return(currentAppDomainManager.CheckSecuritySettings(this));
        }
示例#16
0
        public void JaggedArrays()
        {
            // transparent type
            FrameworkElement [][] fe = new FrameworkElement [0][];
            Assert.IsNotNull(fe, "FrameworkElement[,]");

            // critical type
            AppDomainManager [][] adm = new AppDomainManager [0][];
            Assert.IsNotNull(adm, "AppDomainManager[,]");
        }
示例#17
0
        static When_creating_a_headtracker()
        {
            var manager            = new AppDomainManager();
            var entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);

            entryAssemblyfield.SetValue(manager, Assembly.GetCallingAssembly());

            var domainManagerField = AppDomain.CurrentDomain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);

            domainManagerField.SetValue(AppDomain.CurrentDomain, manager);
        }
示例#18
0
文件: Program.cs 项目: zshehri/zBang
        /// <summary>
        /// Allows setting the Entry Assembly when needed.
        /// Use AssemblyUtilities.SetEntryAssembly() as first line in XNA ad hoc tests
        /// </summary>
        /// <param name="assembly">Assembly to set as entry assembly</param>
        public static void SetEntryAssembly(System.Reflection.Assembly assembly)
        {
#if NET462
            AppDomainManager manager            = new AppDomainManager();
            FieldInfo        entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);
            entryAssemblyfield.SetValue(manager, assembly);

            AppDomain domain             = AppDomain.CurrentDomain;
            FieldInfo domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);
            domainManagerField.SetValue(domain, manager);
#endif
        }
示例#19
0
        internal static HostExecutionContextManager GetCurrentHostExecutionContextManager()
        {
            // this is called during AppDomainManager initialization, this is a thread safe place
            // to setup the HostExecutionContextManager for the current AppDomain
            AppDomainManager mgr = AppDomainManager.CurrentAppDomainManager;

            if (mgr != null)
            {
                return(mgr.HostExecutionContextManager);
            }
            return(null);
        }
        private void SetCurrentAssembly()
        {
            var assembly                        = Assembly.GetCallingAssembly();
            AppDomainManager manager            = new AppDomainManager();
            FieldInfo        entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);

            entryAssemblyfield.SetValue(manager, assembly);
            AppDomain domain             = AppDomain.CurrentDomain;
            FieldInfo domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);

            domainManagerField.SetValue(domain, manager);
        }
示例#21
0
        /// <summary>
        /// Allows setting the Entry Assembly when needed.
        /// Use AssemblyUtilities.SetEntryAssembly() as first line in XNA ad hoc tests
        /// </summary>
        /// <param name="assembly">Assembly to set as entry assembly</param>
        public static void SetEntryAssembly(Assembly assembly)
        {
            var manager            = new AppDomainManager();
            var entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);

            entryAssemblyfield.SetValue(manager, assembly);

            var domain             = AppDomain.CurrentDomain;
            var domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);

            domainManagerField.SetValue(domain, manager);
        }
示例#22
0
        public string Process()
        {
            using (AssemblyHelper.SubscribeResolveForAssembly(_options.AssemblyFilePath))
            {
                var appDomainConfig = $"{_options.AssemblyFilePath}.config";
                if (!File.Exists(appDomainConfig))
                {
                    appDomainConfig = null;
                }
                var appDomain = new AppDomainManager(_options.AssemblyFilePath, appDomainConfig, false, null);

                var specFlowVersion = GetSpecFlowVersion();
                var discovererType  = typeof(SpecFlowV30P220Discoverer); // assume recent version
                if (specFlowVersion != null)
                {
                    var versionNumber =
                        ((specFlowVersion.FileMajorPart * 100) + specFlowVersion.FileMinorPart) * 1000 + specFlowVersion.FileBuildPart;

                    if (versionNumber >= 3_00_220)
                    {
                        discovererType = typeof(SpecFlowV30P220Discoverer);
                    }
                    else if (versionNumber >= 3_00_000)
                    {
                        discovererType = typeof(SpecFlowV30Discoverer);
                    }
                    else if (versionNumber >= 2_02_000)
                    {
                        discovererType = typeof(SpecFlowV22Discoverer);
                    }
                    else if (versionNumber >= 2_01_000)
                    {
                        discovererType = typeof(SpecFlowV21Discoverer);
                    }
                    else if (versionNumber >= 2_00_000)
                    {
                        discovererType = typeof(SpecFlowV20Discoverer);
                    }
                    else if (versionNumber >= 1_09_000)
                    {
                        discovererType = typeof(SpecFlowV19Discoverer);
                    }
                }

                appDomain.CreateObjectFrom <AssemblyHelper>(typeof(AssemblyHelper).Assembly.Location, typeof(AssemblyHelper).FullName, _options.TargetFolder);
                appDomain.CreateObjectFrom <AssemblyHelper>(typeof(AssemblyHelper).Assembly.Location, typeof(AssemblyHelper).FullName, _options.ConnectorFolder);
                using (var discoverer = appDomain.CreateObject <IRemotingSpecFlowDiscoverer>(discovererType.Assembly.GetName(), discovererType.FullName))
                {
                    return(discoverer.Discover(_options.AssemblyFilePath, _options.ConfigFilePath));
                }
            }
        }
示例#23
0
        private static void InitEntryAssembly()
        {
            var assembly           = Assembly.GetCallingAssembly();
            var manager            = new AppDomainManager();
            var entryAssemblyField = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);

            entryAssemblyField?.SetValue(manager, assembly);

            var domain             = AppDomain.CurrentDomain;
            var domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);

            domainManagerField?.SetValue(domain, manager);
        }
示例#24
0
    public void TestAssemblySetup()
    {
#if NET46
        // recent SAP HANA provider uses Assembly.GetEntryAssembly() calls during native dlls discovery, which
        // leads to NRE as it returns null under NETFX, so we need to fake this method result to unblock HANA testing
        // https://github.com/microsoft/vstest/issues/1834
        // https://dejanstojanovic.net/aspnet/2015/january/set-entry-assembly-in-unit-testing-methods/
        var assembly = Assembly.GetCallingAssembly();

        var manager            = new AppDomainManager();
        var entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);
        entryAssemblyfield.SetValue(manager, assembly);

        var domain             = AppDomain.CurrentDomain;
        var domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);
        domainManagerField.SetValue(domain, manager);
#endif

        // netcoreapp2.1 adds DbProviderFactories support, but providers should be registered by application itself
        // this code allows to load assembly using factory without adding explicit reference to project
        RegisterSapHanaFactory();
        RegisterSqlCEFactory();

#if !NETCOREAPP2_1 && !AZURE
        // configure assembly redirect for referenced assemblies to use version from GAC
        // this solves exception from provider-specific tests, when it tries to load version from redist folder
        // but loaded from GAC assembly has other version
        AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
        {
            var requestedAssembly = new AssemblyName(args.Name);

            if (requestedAssembly.Name == "IBM.Data.DB2")
            {
                return(DbProviderFactories.GetFactory("IBM.Data.DB2").GetType().Assembly);
            }

            if (requestedAssembly.Name == "IBM.Data.Informix")
            {
                // chose your red or blue pill carefully
                //return DbProviderFactories.GetFactory("IBM.Data.Informix").GetType().Assembly;
                return(typeof(IBM.Data.Informix.IfxTimeSpan).Assembly);
            }

            return(null);
        };
#endif

        // register test providers
        TestNoopProvider.Init();
        SQLiteMiniprofilerProvider.Init();
    }
示例#25
0
        private static void OnMainWindowLaunch(MainWindow mainWindow)
        {
            _version = typeof(Program).Assembly.GetCustomAttribute <AssemblyFileVersionAttribute>().Version;
            App.Logger.Log($"FrostySoundImport by DanDev - Version {_version}");

            // hack because Frosty calls GetEntryAssembly() which returns null normally
            var domainManager2 = new AppDomainManager();

            domainManager2.SetFieldValue("m_entryAssembly", Application.ResourceAssembly);
            AppDomain.CurrentDomain.SetFieldValue("_domainManager", domainManager2);

            _tabControl = mainWindow.GetFieldValue <FrostyTabControl>("tabControl");
            _tabControl.SelectionChanged += TabControlOnSelectionChanged;
        }
示例#26
0
        public void UnloadAgents()
        {
            if (LoadedAgents == null)
            {
                return;
            }
            AppDomainManager adm = new AppDomainManager();

            foreach (SecurityAgent agent in LoadedAgents.Keys)
            {
                AppDomain.Unload(agent.AppDomain);
            }
            LoadedAgents.Clear();
        }
示例#27
0
        public void Initialize()
        {
            Assembly assembly = Assembly.GetAssembly(GetType());

            AppDomainManager manager            = new AppDomainManager();
            FieldInfo        entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);

            entryAssemblyfield.SetValue(manager, assembly);

            AppDomain domain             = AppDomain.CurrentDomain;
            FieldInfo domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);

            domainManagerField.SetValue(domain, manager);
        }
示例#28
0
    public void TestAssemblySetup()
    {
#if !NETSTANDARD1_6 && !NETSTANDARD2_0 && !APPVEYOR && !TRAVIS
        // recent SAP HANA provider uses Assembly.GetEntryAssembly() calls during native dlls discovery, which
        // leads to NRE as it returns null under NETFX, so we need to fake this method result to unblock HANA testing
        // https://github.com/microsoft/vstest/issues/1834
        // https://dejanstojanovic.net/aspnet/2015/january/set-entry-assembly-in-unit-testing-methods/
        var assembly = Assembly.GetCallingAssembly();

        var manager            = new AppDomainManager();
        var entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);
        entryAssemblyfield.SetValue(manager, assembly);

        var domain             = AppDomain.CurrentDomain;
        var domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);
        domainManagerField.SetValue(domain, manager);
#endif

#if !NETSTANDARD1_6 && !NETSTANDARD2_0 && !APPVEYOR && !TRAVIS
        // configure assembly redirect for referenced assemblies to use version from GAC
        // this solves exception from provider-specific tests, when it tries to load version from redist folder
        // but loaded from GAC assembly has other version
        AppDomain.CurrentDomain.AssemblyResolve += (sender, args) =>
        {
            var requestedAssembly = new AssemblyName(args.Name);
            if (requestedAssembly.Name == "IBM.Data.DB2")
            {
                return(DbProviderFactories.GetFactory("IBM.Data.DB2").GetType().Assembly);
            }
            if (requestedAssembly.Name == "IBM.Data.Informix")
            {
                // chose your red or blue pill carefully
                //return DbProviderFactories.GetFactory("IBM.Data.Informix").GetType().Assembly;
                return(typeof(IBM.Data.Informix.IfxTimeSpan).Assembly);
            }

            return(null);
        };
#endif

        // register test providers
        TestNoopProvider.Init();

        // disabled for core, as default loader doesn't allow multiple assemblies with same name
        // https://github.com/dotnet/coreclr/blob/master/Documentation/design-docs/assemblyloadcontext.md
#if !NETSTANDARD1_6 && !NETSTANDARD2_0
        Npgsql4PostgreSQLDataProvider.Init();
#endif
    }
示例#29
0
        public BasicTestsBase()
        {
            /* Preparing test start */
            Assembly         assembly           = Assembly.GetCallingAssembly();
            AppDomainManager manager            = new AppDomainManager();
            FieldInfo        entryAssemblyfield = manager.GetType().GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);

            entryAssemblyfield.SetValue(manager, assembly);

            AppDomain domain             = AppDomain.CurrentDomain;
            FieldInfo domainManagerField = domain.GetType().GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);

            domainManagerField.SetValue(domain, manager);
            /* Preparing test end */
        }
        private static void FixEntryAssembly()
        {
            // http://dejanstojanovic.net/aspnet/2015/january/set-entry-assembly-in-unit-testing-methods/
            AppDomainManager manager            = new AppDomainManager();
            FieldInfo        entryAssemblyfield = manager.GetType()
                                                  .GetField("m_entryAssembly", BindingFlags.Instance | BindingFlags.NonPublic);

            entryAssemblyfield?.SetValue(manager, typeof(Startup).Assembly);

            AppDomain domain             = AppDomain.CurrentDomain;
            FieldInfo domainManagerField = domain.GetType()
                                           .GetField("_domainManager", BindingFlags.Instance | BindingFlags.NonPublic);

            domainManagerField?.SetValue(domain, manager);
        }
		/// <summary>
		/// Creates a new <see cref="AppDomainManager"/> instance.
		/// </summary>
		/// <param name="domainName">Name of the domain.</param>
		/// <param name="configurationFile">Configuration file.</param>
		/// <param name="shadowCopyDirectories">Shadow copy directories.</param>
		public AppDomainManager(string basedir, string domainName, string configurationFile, params string[] shadowCopyDirectories)
		{
			this.domainName = domainName;
			this.domainType = DomainType.Remote;

			if(log.IsDebugEnabled) log.Debug("Loading new AppDomainManager");

			Evidence baseEvidence = AppDomain.CurrentDomain.Evidence;
			Evidence evidence = new Evidence(baseEvidence);

			AppDomainSetup setup = new AppDomainSetup();
			setup.ApplicationBase = basedir;
			setup.ApplicationName = "Test";
			if(configurationFile.Length > 0) setup.ConfigurationFile = configurationFile;

			if(log.IsDebugEnabled)
			{
				log.Debug("ApplicationBase: " + setup.ApplicationBase);
				log.Debug("ApplicationName: " + setup.ApplicationName);
				log.Debug("ConfigurationFile: " + setup.ConfigurationFile);
			}

			if(shadowCopyDirectories != null && shadowCopyDirectories.Length >= 0)
			{
				guid = System.Guid.NewGuid().ToString();
				setup.ShadowCopyFiles = "true";
				setup.CachePath = this.GetCachePath();
				foreach (string shadowCopyDirectory in shadowCopyDirectories)
				{
					string dir = String.Empty;

					if(File.Exists(shadowCopyDirectory))
					{
						// if it's a file, grab the directory name
						FileInfo f = new FileInfo(shadowCopyDirectory);
						dir = f.DirectoryName;
					}
					else
					{
						dir = shadowCopyDirectory;
					}
					
					if(setup.ShadowCopyDirectories != null && setup.ShadowCopyDirectories.Length > 0)
					{
						setup.ShadowCopyDirectories += ";" + dir;
					}
					else
					{
						setup.ShadowCopyDirectories += dir;
					}
				}
			}

			domain = AppDomain.CreateDomain(this.domainName, evidence, setup);
			remote = (AppDomainManager)domain.CreateInstanceAndUnwrap(typeof(AppDomainManager).Assembly.FullName, typeof(AppDomainManager).FullName);
		}
示例#32
0
        public void AddRegion(Scene Sceneworld)
        {
            m_log.Info("[" + ScriptEngineName + "]: ScriptEngine initializing");

            m_Scene = Sceneworld;

            // Make sure we have config
            if (ConfigSource.Configs[ScriptEngineName] == null)
                ConfigSource.AddConfig(ScriptEngineName);

            ScriptConfigSource = ConfigSource.Configs[ScriptEngineName];

            m_enabled = ScriptConfigSource.GetBoolean("Enabled", true);
            if (!m_enabled)
                return;

            // Create all objects we'll be using
            m_EventQueueManager = new EventQueueManager(this);
            m_EventManager = new EventManager(this, true);

            // We need to start it
            m_ScriptManager = new ScriptManager(this);
            m_ScriptManager.Setup();
            m_AppDomainManager = new AppDomainManager(this);
            if (m_MaintenanceThread == null)
                m_MaintenanceThread = new MaintenanceThread();

            m_log.Info("[" + ScriptEngineName + "]: Reading configuration "+
                    "from config section \"" + ScriptEngineName + "\"");

            ReadConfig();

            m_Scene.StackModuleInterface<IScriptModule>(this);
        }
示例#33
0
        public void AddRegion(Scene scene)
        {
            if (!m_enabled)
                return;

            //Register the console commands
            if (FirstStartup)
            {
                scene.AddCommand(this, "ADNE", "ADNE", "Subcommands for Aurora DotNet Engine", AuroraDotNetConsoleCommands);
                scene.AddCommand(this, "help ADNE", "help ADNE", "Brings up the help for ADNE", AuroraDotNetConsoleHelp);

                //Fire this once to make sure that the APIs are found later...
                GetAPIs();

                // Create all objects we'll be using
                ScriptProtection = new ScriptProtectionModule(Config);

                EventManager = new EventManager(this);

                Compiler = new Compiler(this);

                AppDomainManager = new AppDomainManager(this);

                ScriptErrorReporter = new ScriptErrorReporter(Config);

                AssemblyResolver = new AssemblyResolver(ScriptEnginesPath);
            }
            
            FirstStartup = false;

        	m_Scenes.Add(scene);

            scene.StackModuleInterface<IScriptModule>(this);
        }