Net 1.1 Windows Service v.s. Net 2.0 Windows Service

J

Joe

In all of my C#/Net 1.1 services (VS2003), I always have dual mode
functionality. By passing a specific command line argument, the service
would run in Console mode as a Console App instead of as a service. This
always worked well!! However, the Windows Service in NET 2.0 (VS2005) is
structured completely different, and I'm unsure how to continue with this
practice. Could anyone please help me out?

In Net 1.1, here's how my main() would usually look:

// The main entry point for the process
static void Main(string[] args)
{
if ((args.Length > 0) && ("/?" == args[0]))
{
Console.WriteLine("Usage: QWatcher [/?] [/debug]");
Console.WriteLine(" /? Displays this help dialog");
Console.WriteLine(" /debug Service as an application rather");
}
else if ((args.Length > 0) && ("/debug" == args[0].ToLower()))
{
QWatcher oWatcher = new QWatcher();
oWatcher.AppSettings.DebugMode = true;
oWatcher.OnStart(new string[1]);
}
else
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new QWatcher()
};
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
}

Plus, in the Windows Service under Net 1.1 (VS2003), there was an option
to automatically add an instaler for services. Either this is no longer
there under Net 2.0 (VS2005) or it's been moved somewhere... Could
someone help me out here as well please?

Thanx!
 
J

Joe

WooHoo, I done got it figured out... thanx anyways...


In all of my C#/Net 1.1 services (VS2003), I always have dual mode
functionality. By passing a specific command line argument, the service
would run in Console mode as a Console App instead of as a service.
This always worked well!! However, the Windows Service in NET 2.0
(VS2005) is structured completely different, and I'm unsure how to
continue with this practice. Could anyone please help me out?

In Net 1.1, here's how my main() would usually look:

// The main entry point for the process
static void Main(string[] args)
{
if ((args.Length > 0) && ("/?" == args[0]))
{
Console.WriteLine("Usage: QWatcher [/?] [/debug]");
Console.WriteLine(" /? Displays this help dialog");
Console.WriteLine(" /debug Service as an application rather");
}
else if ((args.Length > 0) && ("/debug" == args[0].ToLower()))
{
QWatcher oWatcher = new QWatcher();
oWatcher.AppSettings.DebugMode = true;
oWatcher.OnStart(new string[1]);
}
else
{
System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new
QWatcher() };
System.ServiceProcess.ServiceBase.Run(ServicesToRun);
}
}

Plus, in the Windows Service under Net 1.1 (VS2003), there was an option
to automatically add an instaler for services. Either this is no longer
there under Net 2.0 (VS2005) or it's been moved somewhere... Could
someone help me out here as well please?

Thanx!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top