View Code
public class RemotingWork : MarshalByRefObject { public void test() { int sum = 1; for (int i = 1; i <= 100; i++) { sum += i; } Atom.EventLog.Log.Write("sum=" + sum,""); } }
Create a service program
View Code
[RunInstaller (true)] public partial class ProjectInstaller: System. configuration. install. installer {public ProjectInstaller () {InitializeComponent (); this. committed + = new InstallEventHandler (ProjectInstaller_Committed); // register the event service to automatically start after installation.} private void ProjectInstaller_Committed (object sender, InstallEventArgs e) {System. serviceProcess. serviceController controller = new System. serviceProcess. serviceController ("VAV_TL"); controller. start ();}}
VAV_TL service, VAV_TL is the service name
View Code
public partial class VAV_TL : ServiceBase { public VAV_TL() { InitializeComponent(); } protected override void OnStart(string[] args) { RemotingService.RemotingServer.GetInstance().Start(); } protected override void OnStop() { } }