Results 1 to 6 of 6

Thread: Application.StartupPath for Service

  1. #1

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690

    Application.StartupPath for Service

    Is there an equivelent to Application.StartupPath for a Windows Service?

    The Application object doesn't seem to be available for a service, and I'd like my user-defined parameters (stored in xml) to be stored in the application's directory. By default, the "start-in" directory for a service seems to be (on my machine) c:\winnt\system32.

    TIA,
    Mike

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    VB Code:
    1. System.Windows.Forms.MessageBox.Show(System.Windows.Forms.Application.StartupPath)

    or use this at the top of your code

    VB Code:
    1. Imports System.Windows.Forms

  3. #3

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Shoot. Thought that was the answer, thanks Pirate, but not so.

    System.Windows... is not available. That is, IntelliSense doesn't show it in the list after System, if you type it in, you get that blue underline and the tool tip is "Namespace or type 'Forms' for the Imports 'System.Windows.Forms' cannot be found."

    It's not a typo, either. When I go to a regular Windows form-type application, I can Import it.

    I started this project using the built-in stuff, choosing a Windows service.

    There must be something somewhere that is not letting a generated service-type app access the stuff a form-type app can.

    Either that or I'm missing something really basic.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Can you check if your proj is referecing System.Windows.Forms.dll in the References item in Solution Explorer? though , this would be included by default but just to check it exists .

  5. #5

    Thread Starter
    Frenzied Member Mike Hildner's Avatar
    Join Date
    Jul 2002
    Location
    Des Moines, NM
    Posts
    1,690
    Cool, thanks. That was it. I guess by default, a service does not automatically reference System.Windows.Forms.dll. Add the reference, and all is well.

    Thanks again,
    Mike

  6. #6
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Oops, that's right .When I pasted 'Windows Forms' timer not 'Components' Timer, it automatically add reference to S.W.F.dll , so when I checked my service example , it's there . That fooled me anyways .

    Glad it's working now

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width