ToeKnee,
Does it only run as a Service on a single machine?
If it only runs on as a Service on a single machine or a limited number of
machines, I would (seriously) consider adding a custom section to the
app.config that indicates to use the custom redundancy/hot-standby logic.
The custom section would tell the component "what mode the app is in"...
The component would "fail gracefully" if this custom section is not
available (Allowing the console applications to have a "bare" app.config).
This way if you ever need to allow the console version to support custom
redundancy/hot-standby logic, its a matter of modifying the app.config. Like
wise if you ever need to run the service on a different server, its a matter
of modifying the app.config.
Of course if you have multiple Virtual Servers then updating all of the
app.configs may be more work...
I would use a custom section over appSettings to ensure proper isolation. I
normally make the custom section name reflect (or at least closely related
to) the namespace of the component...
For information on custom sections in the app.config see:
http://msdn.microsoft.com/library/de...onhandlers.asp http://msdn.microsoft.com/library/de...onhandlers.asp http://msdn.microsoft.com/library/de...onsections.asp http://msdn.microsoft.com/library/de...tiongroups.asp
Hope this helps
Jay
"ToeKnee" <To*****@discussions.microsoft.com> wrote in message
news:19**********************************@microsof t.com...
John,
Well, the architecture of the toplevel application is that when it is
running as a Service, it is assumed to be in a special environment (in a
Virtual Server with some custom redundancy/hot-standby logic that the
component has to support). But when they run it as an Console
Application,
it does not need to that hot-standby logic.
Unfortunately the "architects" of this stuff "forgot" to explicitly tell
any of the components what mode the app is in (Console vs. Windows
Service).
This stuff is deployed in many locations and it is for us mere component
developers to figure this out bow..l. we're too late in the game and I am
sure theer has to be a way in C#/.NET to figure this out... but I'm not
having any luck yet....
I know you are curious as to "why" I am needing this, but assuimng that I
really do (and hoping I really have explored most other avenues), can you
tell me "how" I would go about achieving this? THANKS A LOT!!
-ToeKnee
"John Saunders" wrote:
"ToeKnee" <To*****@discussions.microsoft.com> wrote in message
news:57**********************************@microsof t.com... > Robby,
>
> Thanks for your reply. But for reasons that are beyond my control, I do
> need
> to automatically infer if the component is instantiated inside a
> service
> or
> application. I cannot change the interface and have to rely on some
> automated
> mechanism of detecting if the component is running within a Service or
> Application? Any other suggestions??
What aspect of your component needs to change because it's in a service?
In
other words, "whether I'm in a service" is an implementation detail.
Something like "where should I write my output" is more general and makes
better sense.
John Saunders