Solved

ServiceController Modifiers?

Posted on 2006-06-24
4
212 Views
Last Modified: 2010-07-27
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?


0
Comment
Question by:kvnsdr
  • 2
  • 2
4 Comments
 
LVL 96

Expert Comment

by:Bob Learned
Comment Utility
If you are calling outside of the service, you need public scope.  What kind of protection are you looking for?

Bob
0
 
LVL 1

Author Comment

by:kvnsdr
Comment Utility
The most without cutting off my nose.

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

0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 125 total points
Comment Utility
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
 
LVL 1

Author Comment

by:kvnsdr
Comment Utility
Thank you
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now