What is the proper way to determine an application's location?

.net, c#, installation, windows, windows-services

Solution

If you mean that the service starts a different app, then; options:

- configure the service with a config file; put the path in there

- put something in the registry during installation

- use something akin to COM/COM+ registrations

- consider the GAC if the other app is .NET (although I'm not a fan...)

- environment variable?

Personally, I like the config file option; it is simple and easy to maintain, and allows multiple separate (side-by-side) service and app installs

Problem

I'm writing a windows service in C# that spawns multiple instances of another application I am writing. There is a chance that the application can be installed anywhere on a machine. What is the best way to let the service know where the application is located?

Original source