Click here to Skip to main content
15,891,375 members
Home / Discussions / C#
   

C#

 
GeneralRe: Getting the bin directory location for a service??!! Pin
justintimberlake2-May-07 18:57
justintimberlake2-May-07 18:57 
GeneralRe: Getting the bin directory location for a service??!! Pin
LongRange.Shooter2-May-07 5:30
LongRange.Shooter2-May-07 5:30 
GeneralRe: Getting the bin directory location for a service??!! Pin
justintimberlake2-May-07 19:05
justintimberlake2-May-07 19:05 
AnswerThe only thing that works with a service in the 2.0 framework Pin
LongRange.Shooter3-May-07 1:43
LongRange.Shooter3-May-07 1:43 
AnswerRe: Getting the bin directory location for a service??!! Pin
PIEBALDconsult3-May-07 15:31
mvePIEBALDconsult3-May-07 15:31 
GeneralRe: Getting the bin directory location for a service??!! Pin
LongRange.Shooter4-May-07 3:01
LongRange.Shooter4-May-07 3:01 
GeneralRe: Getting the bin directory location for a service??!! Pin
PIEBALDconsult4-May-07 16:47
mvePIEBALDconsult4-May-07 16:47 
GeneralRe: Getting the bin directory location for a service??!! Pin
PIEBALDconsult6-May-07 14:14
mvePIEBALDconsult6-May-07 14:14 
I just tried it in the OnStart of one of my complex services, both debug and release builds.

System.Windows.Application.ExecutablePath and System.Windows.Application.StartupPath
gave the information about the executable that loaded the DLL, which is still good for simple services, but not here.

System.Reflection.Assembly.GetExecutingAssembly().CodeBase
gave the name of the actual file containing the executing code

However! My OnStart is in a base class in another DLL so I got information on that, including when in release mode the particular DLL in in the GAC!

So, I wrote an override of OnStart in my service class and I got the expected result.

But at no time did System.Reflection.Assembly.GetExecutingAssembly() return null, I am still most curious your statement that yours did.


At any rate, I doubt that OnStart() is the proper place for the code you're trying to run, it should be very small, my version is:

C#
        protected override void
        OnStart
        (
            string[] args
        )
        {
# if DEBUG
            System.Threading.Thread.Sleep ( 60000 ) ;
# endif        
            this.oktoproceed = true ;

            base.OnStart ( args ) ;

            if ( this.when != null )
            {            
                this.when.Start() ;
            }
            
            LogMessage ( this.ServiceName + " started" ) ;
        }


(when is a System.Timers.Timer that controls the cycling of the service)
QuestionThread creation using reflection for the target? Pin
LongRange.Shooter1-May-07 9:55
LongRange.Shooter1-May-07 9:55 
AnswerRe: Thread creation using reflection for the target? Pin
Ian Shlasko1-May-07 10:21
Ian Shlasko1-May-07 10:21 
GeneralRe: Thread creation using reflection for the target? Pin
LongRange.Shooter1-May-07 10:58
LongRange.Shooter1-May-07 10:58 
AnswerRe: Thread creation using reflection for the target? Pin
PIEBALDconsult1-May-07 18:26
mvePIEBALDconsult1-May-07 18:26 
QuestionC# Remote Window Hooks Pin
Bourtree1-May-07 9:40
Bourtree1-May-07 9:40 
AnswerRe: C# Remote Window Hooks Pin
LongRange.Shooter1-May-07 11:58
LongRange.Shooter1-May-07 11:58 
GeneralRe: C# Remote Window Hooks Pin
Bourtree3-May-07 6:51
Bourtree3-May-07 6:51 
GeneralRe: C# Remote Window Hooks Pin
LongRange.Shooter3-May-07 14:56
LongRange.Shooter3-May-07 14:56 
Questionarray of reference type in heap Pin
swjam1-May-07 8:59
swjam1-May-07 8:59 
AnswerRe: array of reference type in heap Pin
Ian Shlasko1-May-07 9:13
Ian Shlasko1-May-07 9:13 
AnswerRe: array of reference type in heap Pin
kubben1-May-07 9:14
kubben1-May-07 9:14 
GeneralRe: array of reference type in heap Pin
Ian Shlasko1-May-07 9:19
Ian Shlasko1-May-07 9:19 
GeneralRe: array of reference type in heap Pin
kubben1-May-07 9:22
kubben1-May-07 9:22 
AnswerRe: array of reference type in heap Pin
LongRange.Shooter1-May-07 9:50
LongRange.Shooter1-May-07 9:50 
AnswerRe: array of reference type in heap Pin
Guffa1-May-07 9:52
Guffa1-May-07 9:52 
QuestionProblme passing Double Quotes (") to query Pin
Muhammad Nauman Yousuf1-May-07 6:54
Muhammad Nauman Yousuf1-May-07 6:54 
AnswerRe: Problme passing Double Quotes (") to query Pin
kubben1-May-07 7:15
kubben1-May-07 7:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.