Ejemplo n.º 1
0
        protected void LoadInAppDomain(string fullTypeName, ASCOMClient ascomClient)
        {
            string[] tokens = fullTypeName.Split(new char[] { ',' }, 2);
            m_AssemblyName = new AssemblyName(tokens[1]);

            var appSetup = new AppDomainSetup()
            {
                ApplicationName = "OccuRec",
                ApplicationBase = AppDomain.CurrentDomain.BaseDirectory,
                ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
            };

            m_DomainName = string.Format("{0}{1}.v{2}", APP_DOMAIN_PREFIX, m_AssemblyName.Name, m_AssemblyName.Version != null ? m_AssemblyName.Version.ToString() : "XX");

            var e = new Evidence();
            e.AddHostEvidence(new Zone(SecurityZone.MyComputer));
            PermissionSet pset = SecurityManager.GetStandardSandbox(e);

            m_HostDomain = AppDomain.CreateDomain(m_DomainName, AppDomain.CurrentDomain.Evidence, appSetup, pset, null);
            m_HostDomain.AssemblyResolve += m_HostDomain_AssemblyResolve;
            m_HostDomain.ReflectionOnlyAssemblyResolve += m_HostDomain_AssemblyResolve;
            m_HostDomain.UnhandledException += m_HostDomain_UnhandledException;
            m_HostDomain.DomainUnload += m_HostDomain_DomainUnload;

            object obj = m_HostDomain.CreateInstanceAndUnwrap(tokens[1], tokens[0]);

            ascomClient.RegisterLifetimeService(obj as MarshalByRefObject);

            m_Instance = (IIsolatedDevice)obj;
            m_Instance.Initialise(new OccuRecHostDelegate(tokens[0], ascomClient));
        }
Ejemplo n.º 2
0
        public ASCOMHelper(ASCOMClient client, bool loadIsolated)
        {
            if (loadIsolated)
                LoadInAppDomain("OccuRec.ASCOM.Server.ASCOMHelper, OccuRec.ASCOM.Server", client);
            else
                LoadInCurrentDomain("OccuRec.ASCOM.Server.ASCOMHelper, OccuRec.ASCOM.Server", client);

            m_IsolatedHelper = m_Instance as IASCOMHelper;
        }
Ejemplo n.º 3
0
 private void frmMain_Load(object sender, EventArgs e)
 {
     m_Client = new ASCOMClient();
     m_Client.Initialise(false);
 }
Ejemplo n.º 4
0
 public OccuRecHostDelegate(string typeName, ASCOMClient ascomClient)
 {
     m_AscomClient = ascomClient;
     m_TypeName = typeName;
 }
Ejemplo n.º 5
0
        protected void LoadInCurrentDomain(string fullTypeName, ASCOMClient ascomClient)
        {
            string[] tokens = fullTypeName.Split(new char[] { ',' }, 2);
            m_AssemblyName = new AssemblyName(tokens[1]);

            m_HostDomain = null;
            Assembly asm = Assembly.Load(m_AssemblyName);
            object obj = asm.CreateInstance(tokens[0]);

            m_Instance = (IIsolatedDevice)obj;
            m_Instance.Initialise(new OccuRecHostDelegate(tokens[0], ascomClient));
        }