void Initialize()
        {
            var currentDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            _serviceEnd1Domain = AppDomain.CreateDomain("ServiceEndDomain1", null, null);
            var serviceEnd1Asm = AssemblyName.GetAssemblyName(Path.Combine(currentDir, ServiceEnd1Dll));

            _serviceEnd1 = (RemoteServiceEnd)_serviceEnd1Domain.CreateInstanceAndUnwrap
                               (serviceEnd1Asm.FullName, ServiceEnd1Type);

            _serviceEnd2Domain = AppDomain.CreateDomain("ServiceEndDomain2", null, null);
            var serviceEnd2Asm = AssemblyName.GetAssemblyName(Path.Combine(currentDir, ServiceEnd2Dll));

            _serviceEnd2 = (RemoteServiceEnd)_serviceEnd2Domain.CreateInstanceAndUnwrap
                               (serviceEnd2Asm.FullName, ServiceEnd2Type);

            // 分别在 3 个 AppDomain 中创建 ShuttleDomain
            _serviceEnd1.CreateShuttleDomain();
            _serviceEnd2.CreateShuttleDomain();
            var key = Guid.NewGuid().ToString();

            _shuttleDomain = ShuttleDomainHelper.Create(key, key);

            // 分别在 3 个 AppDomain 中注册服务
            RegisterServices();
            _serviceEnd1.RegisterServices();
            _serviceEnd2.RegisterServices();
        }
        void Initialize()
        {
            _serviceEnd3Domain = AppDomain.CreateDomain("ServiceEndDomain3", null, null);
            _serviceEnd3       = (RemoteServiceEnd)_serviceEnd3Domain.CreateInstanceAndUnwrap
                                     (typeof(RemoteServiceEnd3).Assembly.FullName, typeof(RemoteServiceEnd3).FullName);

            _serviceEnd4Domain = AppDomain.CreateDomain("ServiceEndDomain4", null, null);
            _serviceEnd4       = (RemoteServiceEnd)_serviceEnd4Domain.CreateInstanceAndUnwrap
                                     (typeof(RemoteServiceEnd4).Assembly.FullName, typeof(RemoteServiceEnd4).FullName);

            // 分别在 3 个 AppDomain 中创建 ShuttleDomain
            _serviceEnd3.CreateShuttleDomain();
            _serviceEnd4.CreateShuttleDomain();
            var key = Guid.NewGuid().ToString();

            _shuttleDomain = ShuttleDomainHelper.Create(key, key);
        }
Example #3
0
        public override bool Setup()
        {
            _remoteDomain = AppDomain.CreateDomain(Guid.NewGuid().ToString(), null, null);
            _remotingFunctionTest = CreateRemoteFunctionTestObject();

            _serviceEnd1 = (RemoteServiceEnd)_remoteDomain.CreateInstanceAndUnwrap
                (_serviceEnd1AsmName, ServiceEnd1Type);

            // 创建 ShuttleDomain
            _serviceEnd1.CreateShuttleDomain();

            var key = Guid.NewGuid().ToString();
            _shuttleDomain = ShuttleDomainHelper.Create(key, key);

            // 注册服务
            _serviceEnd1.RegisterServices();

            return true;
        }