Click here to Skip to main content
15,892,005 members
Articles / Desktop Programming / ATL

TCP Remoting Windows Service Host with Server GC

Rate me:
Please Sign up or sign in to vote.
3.40/5 (3 votes)
14 Apr 2004CPOL4 min read 67.6K   690   20  
Implement Server GC for TCP Remoting Host.
using System;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Runtime.Remoting.Channels.Http;
using System.Diagnostics;


namespace JQD
{
	public class RemoteObjectLoader
	{
		public void Load()
		{
			string appBasePath=AppDomain.CurrentDomain.BaseDirectory;
			// remove release\ or debug\ so that we can get to app.Config
			// Note that Compiling Windows Service code does not move its config file.
            appBasePath=appBasePath.Replace(@"debug\","");
			appBasePath=appBasePath.Replace(@"release\","");
			RemotingConfiguration.Configure(appBasePath + "app.Config");
			EventLog.WriteEntry("Application",appBasePath);

		}

		public void LoadTestOnly()
		{
			// type http://localhost:10002/MyClassURI?WSDL to test
		   ChannelServices.RegisterChannel(new HttpChannel(10002));
		   RemotingConfiguration.RegisterWellKnownServiceType(typeof(JQD.MyClass),
		   "MyClassURI", WellKnownObjectMode.SingleCall);
		}

	}
	public class MyClass : MarshalByRefObject
	{
		public string Test()
		{
			return "Test TCP Remtoing Host with Server GC  ";
		}
	}

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
United States United States
I am a Microsoft Certified Application Developer (MCAD), currently focusing on using .Net Framework to develop Business Solutions. I am mostly language neutral. I have used C, C++, ATL, MFC, VB.Net, C#, VB 6, PL/SQL, Transact SQL, ASP, Fortran, etc.

Comments and Discussions