Exemple #1
0
		public void RegisterActivatedType()
		{
			TcpChannel chn = null;
			try
			{
				chn = new TcpChannel(1234);
				ChannelServices.RegisterChannel(chn);
				
				// register the CAO
				RemotingConfiguration.RegisterActivatedServiceType(typeof(ActivatedObject));
				
				// get the registered CAO
				ActivatedServiceTypeEntry[] ast = RemotingConfiguration.GetRegisteredActivatedServiceTypes();
				
				bool IsServerRegistered = false;
				foreach(ActivatedServiceTypeEntry aste in ast)
				{
					if(aste.ObjectType == typeof(ActivatedObject))
					{
						IsServerRegistered = true;
						break;
					}
				}
				
				Assert.IsTrue(IsServerRegistered, "#A07");
				
				RemotingConfiguration.RegisterActivatedClientType(typeof(DerivedActivatedObject), "tcp://localhost:1234");
				
				ActivatedClientTypeEntry[] act = RemotingConfiguration.GetRegisteredActivatedClientTypes();
				
				bool IsClientRegistered = false;
				foreach(ActivatedClientTypeEntry acte in act)
				{
					if(acte.ObjectType == typeof(DerivedActivatedObject))
					{
						IsClientRegistered = true;
						break;
					}
				}
				
				Assert.IsTrue(IsClientRegistered);				, "#A08");
				
				// This will send a RemotingException since there is no service named DerivedActivatedObject
				// on the server
				DerivedActivatedObject objDerivedActivated = new DerivedActivatedObject();
			}
		public void RegisterActivatedType()
		{
			TcpChannel chn = null;
			try
			{
				chn = new TcpChannel(1234);
				ChannelServices.RegisterChannel(chn);
				
				// register the CAO
				RemotingConfiguration.RegisterActivatedServiceType(typeof(ActivatedObject));
				
				// get the registered CAO
				ActivatedServiceTypeEntry[] ast = RemotingConfiguration.GetRegisteredActivatedServiceTypes();
				
				bool IsServerRegistered = false;
				foreach(ActivatedServiceTypeEntry aste in ast)
				{
					if(aste.ObjectType == typeof(ActivatedObject))
					{
						IsServerRegistered = true;
						break;
					}
				}
				
				Assert.IsTrue(IsServerRegistered, "#A07");
				
				RemotingConfiguration.RegisterActivatedClientType(typeof(DerivedActivatedObject), "tcp://localhost:1234");
				
				ActivatedClientTypeEntry[] act = RemotingConfiguration.GetRegisteredActivatedClientTypes();
				
				bool IsClientRegistered = false;
				foreach(ActivatedClientTypeEntry acte in act)
				{
					if(acte.ObjectType == typeof(DerivedActivatedObject))
					{
						IsClientRegistered = true;
						break;
					}
				}
				
				Assert.IsTrue(IsClientRegistered);				, "#A08");
				
				// This will send a RemotingException since there is no service named DerivedActivatedObject
				// on the server
				DerivedActivatedObject objDerivedActivated = new DerivedActivatedObject();
			}
			finally
			{
				ChannelServices.UnregisterChannel(chn);
			}
			
		}