ServiceController Modifiers?

I recently discoved that using the code below in a win app is useless (always returns 'Stopped') if the serviceController modifiers are set to private, da......

         MessageBox.Show(serviceController1.Status.ToString());

I'm currently using 'Protected'.....................


Q. What is the correct modifer to use for maximum protection yet allow correct return status?


LVL 1
kvnsdrAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Bob LearnedConnect With a Mentor Commented:
The scope modifier needed depends on where it is called from?  Is this called from inside the service instance?

1) 'private' is only visible inside a class
2) 'internal' is only visible within a class, and any other class in an assembly, but not outside.
3) 'protected' with 'static' are visible friend or member function of a derived class.
4) 'protected' without 'static' are visible to friends and inside in a derived class only through a pointer to, reference to, or object of the derived class.
5) 'public' is available everything

It sounds like 'protected' is the best you're gonna get.

Bob
0
 
Bob LearnedCommented:
If you are calling outside of the service, you need public scope.  What kind of protection are you looking for?

Bob
0
 
kvnsdrAuthor Commented:
The most without cutting off my nose.

I'm currently using 'Protected' and all works.

0
 
kvnsdrAuthor Commented:
Thank you
0
All Courses

From novice to tech pro — start learning today.