Exemplo n.º 1
0
        public UserscriptHost(
            byte[] AssemblySerial,
            byte[] AssemblySymbolStoreSerial)
        {
            BeginZait = Bib3.Glob.StopwatchZaitMiliSictInt();

            this.AssemblySerial            = AssemblySerial;
            this.AssemblySymbolStoreSerial = AssemblySymbolStoreSerial;

            if (null == AssemblySerial)
            {
                return;
            }

            if (false)
            {
                //	Weege Probleme mit Debuge (Visual Studio Debugger überspringt Method in Dll) verzict auf AppDomain

                ScriptAppDomain = AppDomain.CreateDomain("UserScript.Instance[" + Ident.ToString() + "]");

                AssemblyLoaded = ScriptAppDomain.Load(AssemblySerial, AssemblySymbolStoreSerial);
            }
            else
            {
                AssemblyLoaded = System.Reflection.Assembly.Load(AssemblySerial, AssemblySymbolStoreSerial);
            }

            var MengeType = AssemblyLoaded.GetTypes();

            ScriptInterfaceType =
                MengeType
                .FirstOrDefaultNullable(PrädikaatTypeIstScriptInterface);

            if (null == ScriptInterfaceType)
            {
                return;
            }

            if (false)
            {
                //	Weege Probleme mit Debuge (Visual Studio Debugger überspringt Method in Dll) verzict auf AppDomain

                ScriptInterfaceWrapped = ScriptAppDomain.CreateInstance(AssemblyLoaded.FullName, ScriptInterfaceType.FullName);

                ScriptInterfaceLease = (System.Runtime.Remoting.Lifetime.ILease)ScriptInterfaceWrapped.InitializeLifetimeService();

                ScriptInterface = (IUserscript)ScriptInterfaceWrapped.Unwrap();
            }
            else
            {
                ScriptInterface = (IUserscript)Activator.CreateInstance(ScriptInterfaceType);
            }
        }