Application.StartupPath

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rick

    #1

    Application.StartupPath

    I have a VB.Net 2005 application that I am publishing to a network file
    server.

    The app reads an xml file that has some database connection information in
    it. This xml file is located in the same folder as the executable.

    The problem is when I double click on the appname.applica tion on the server
    the program can't find the xml file because the Application.Sta rtupPath is:

    C:\Documents and Settings\UserNa me\Local Settings\Apps\2 .0\...

    So it looks like the program is being run from the local client rather than
    the file server.

    Why is that happening and is there some way to find out inside the program
    where the .exe really is located?

    Rick


  • Rick

    #2
    Re: Application.Sta rtupPath

    Well, I figured out part of the problem.

    I'm new to VB.net and did not understand that I was Publishing the
    application and clicking on the .application was installing it on the local
    computer.

    However when I just copy the exe file to the file server (along with the xml
    file for db configuration) I get an unhandled exception. What should I be
    doing to get the exe to run on the server from a common location so all
    clients can access it

    "Rick" <Rick@LakeValle ySeed.comwrote in message
    news:eVh0Qcs%23 GHA.4544@TK2MSF TNGP05.phx.gbl. ..
    >I have a VB.Net 2005 application that I am publishing to a network file
    >server.
    >
    The app reads an xml file that has some database connection information in
    it. This xml file is located in the same folder as the executable.
    >
    The problem is when I double click on the appname.applica tion on the
    server the program can't find the xml file because the
    Application.Sta rtupPath is:
    >
    C:\Documents and Settings\UserNa me\Local Settings\Apps\2 .0\...
    >
    So it looks like the program is being run from the local client rather
    than the file server.
    >
    Why is that happening and is there some way to find out inside the program
    where the .exe really is located?
    >
    Rick
    >

    Comment

    • rowe_newsgroups

      #3
      Re: Application.Sta rtupPath

      I'm guessing you're getting a security access violation? This is due to
      the fact that the .Net code security policy by default doesn't like
      programs deployed on network drives (the permission set for local
      intranet is almost nothing). Anyways, if I'm right then follow the
      bellow steps to change your app's security policy settings.

      Goto control panel --admin tools --Microsoft .Net Framework 2.0
      Configuration. Expand the Runtime Security Policy Node. Expand the
      Machine Level node.
      Expand the Code Groups node. Right click on the All_Code node and
      select "New..." Follow the wizard to build the new permission set (I
      normally use strong name - see the .Net help for how to add a strong
      name to you're solution). After you finish the wizard, you should be go
      to go (on your computer at least!) So before you exit the Framework
      Configuration, right click on "Runtime Security Policy" and select
      "Create Deployment Package" and follow the wizard (be sure to select
      Machine Level). This msi installer has to be run on each computer that
      is going to use your program, and it must be run of the local drive -
      running it from the network drive will not do anything. I had our
      company's Network admin set up a login script to run the installer - I
      think it the easiest way to accomplish it.

      Let me know if that helps,

      Seth Rowe


      Rick wrote:
      Well, I figured out part of the problem.
      >
      I'm new to VB.net and did not understand that I was Publishing the
      application and clicking on the .application was installing it on the local
      computer.
      >
      However when I just copy the exe file to the file server (along with the xml
      file for db configuration) I get an unhandled exception. What should I be
      doing to get the exe to run on the server from a common location so all
      clients can access it
      >
      "Rick" <Rick@LakeValle ySeed.comwrote in message
      news:eVh0Qcs%23 GHA.4544@TK2MSF TNGP05.phx.gbl. ..
      I have a VB.Net 2005 application that I am publishing to a network file
      server.

      The app reads an xml file that has some database connection information in
      it. This xml file is located in the same folder as the executable.

      The problem is when I double click on the appname.applica tion on the
      server the program can't find the xml file because the
      Application.Sta rtupPath is:

      C:\Documents and Settings\UserNa me\Local Settings\Apps\2 .0\...

      So it looks like the program is being run from the local client rather
      than the file server.

      Why is that happening and is there some way to find out inside the program
      where the .exe really is located?

      Rick

      Comment

      • Rick

        #4
        Re: Application.Sta rtupPath

        thanks Seth,

        I'm plodding through this very unfamiliar territory!

        First I had to do a repair on .NET 2.0 since there was no mscorcfg.msc ever
        created for v 2.0. Odd since it should have been installed when I installed
        VS 2005.

        Anyway now I've got that up and running and can proceed.

        Firstly, from what I see about Strong names, it seems they are just for dll
        signing. I have an executable. Is this correct, or is it possible to
        create a strong name for exe's as well?

        Rick

        "rowe_newsgroup s" <rowe_email@yah oo.comwrote in message
        news:1162093457 .340603.113830@ m7g2000cwm.goog legroups.com...
        I'm guessing you're getting a security access violation? This is due to
        the fact that the .Net code security policy by default doesn't like
        programs deployed on network drives (the permission set for local
        intranet is almost nothing). Anyways, if I'm right then follow the
        bellow steps to change your app's security policy settings.
        >
        Goto control panel --admin tools --Microsoft .Net Framework 2.0
        Configuration. Expand the Runtime Security Policy Node. Expand the
        Machine Level node.
        Expand the Code Groups node. Right click on the All_Code node and
        select "New..." Follow the wizard to build the new permission set (I
        normally use strong name - see the .Net help for how to add a strong
        name to you're solution). After you finish the wizard, you should be go
        to go (on your computer at least!) So before you exit the Framework
        Configuration, right click on "Runtime Security Policy" and select
        "Create Deployment Package" and follow the wizard (be sure to select
        Machine Level). This msi installer has to be run on each computer that
        is going to use your program, and it must be run of the local drive -
        running it from the network drive will not do anything. I had our
        company's Network admin set up a login script to run the installer - I
        think it the easiest way to accomplish it.
        >
        Let me know if that helps,
        >
        Seth Rowe
        >
        >
        Rick wrote:
        >Well, I figured out part of the problem.
        >>
        >I'm new to VB.net and did not understand that I was Publishing the
        >application and clicking on the .application was installing it on the
        >local
        >computer.
        >>
        >However when I just copy the exe file to the file server (along with the
        >xml
        >file for db configuration) I get an unhandled exception. What should I
        >be
        >doing to get the exe to run on the server from a common location so all
        >clients can access it
        >>
        >"Rick" <Rick@LakeValle ySeed.comwrote in message
        >news:eVh0Qcs%2 3GHA.4544@TK2MS FTNGP05.phx.gbl ...
        >I have a VB.Net 2005 application that I am publishing to a network file
        >server.
        >
        The app reads an xml file that has some database connection information
        in
        it. This xml file is located in the same folder as the executable.
        >
        The problem is when I double click on the appname.applica tion on the
        server the program can't find the xml file because the
        Application.Sta rtupPath is:
        >
        C:\Documents and Settings\UserNa me\Local Settings\Apps\2 .0\...
        >
        So it looks like the program is being run from the local client rather
        than the file server.
        >
        Why is that happening and is there some way to find out inside the
        program
        where the .exe really is located?
        >
        Rick
        >
        >

        Comment

        • rowe_newsgroups

          #5
          Re: Application.Sta rtupPath

          You can strong name an exe. Just go to your project properties - it's
          on one of the tabs there.

          Thanks,

          Seth Rowe


          Rick wrote:
          thanks Seth,
          >
          I'm plodding through this very unfamiliar territory!
          >
          First I had to do a repair on .NET 2.0 since there was no mscorcfg.msc ever
          created for v 2.0. Odd since it should have been installed when I installed
          VS 2005.
          >
          Anyway now I've got that up and running and can proceed.
          >
          Firstly, from what I see about Strong names, it seems they are just for dll
          signing. I have an executable. Is this correct, or is it possible to
          create a strong name for exe's as well?
          >
          Rick
          >
          "rowe_newsgroup s" <rowe_email@yah oo.comwrote in message
          news:1162093457 .340603.113830@ m7g2000cwm.goog legroups.com...
          I'm guessing you're getting a security access violation? This is due to
          the fact that the .Net code security policy by default doesn't like
          programs deployed on network drives (the permission set for local
          intranet is almost nothing). Anyways, if I'm right then follow the
          bellow steps to change your app's security policy settings.

          Goto control panel --admin tools --Microsoft .Net Framework 2.0
          Configuration. Expand the Runtime Security Policy Node. Expand the
          Machine Level node.
          Expand the Code Groups node. Right click on the All_Code node and
          select "New..." Follow the wizard to build the new permission set (I
          normally use strong name - see the .Net help for how to add a strong
          name to you're solution). After you finish the wizard, you should be go
          to go (on your computer at least!) So before you exit the Framework
          Configuration, right click on "Runtime Security Policy" and select
          "Create Deployment Package" and follow the wizard (be sure to select
          Machine Level). This msi installer has to be run on each computer that
          is going to use your program, and it must be run of the local drive -
          running it from the network drive will not do anything. I had our
          company's Network admin set up a login script to run the installer - I
          think it the easiest way to accomplish it.

          Let me know if that helps,

          Seth Rowe


          Rick wrote:
          Well, I figured out part of the problem.
          >
          I'm new to VB.net and did not understand that I was Publishing the
          application and clicking on the .application was installing it on the
          local
          computer.
          >
          However when I just copy the exe file to the file server (along with the
          xml
          file for db configuration) I get an unhandled exception. What should I
          be
          doing to get the exe to run on the server from a common location so all
          clients can access it
          >
          "Rick" <Rick@LakeValle ySeed.comwrote in message
          news:eVh0Qcs%23 GHA.4544@TK2MSF TNGP05.phx.gbl. ..
          I have a VB.Net 2005 application that I am publishing to a network file
          server.

          The app reads an xml file that has some database connection information
          in
          it. This xml file is located in the same folder as the executable.

          The problem is when I double click on the appname.applica tion on the
          server the program can't find the xml file because the
          Application.Sta rtupPath is:

          C:\Documents and Settings\UserNa me\Local Settings\Apps\2 .0\...

          So it looks like the program is being run from the local client rather
          than the file server.

          Why is that happening and is there some way to find out inside the
          program
          where the .exe really is located?

          Rick

          Comment

          Working...