Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to run application from network folder

How to run application from network folder

Scheduled Pinned Locked Moved C#
csharphelpwinformssysadmintutorial
18 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Simon P Stevens

    It's because of the trust level assigned to the app. .net exe files run off of a network share are assigned a low trust level. (As opposed to full trust when run locally). If you want your app to automatically just work from a network share you need to design it so it doesn't require full trust. This means you can't do anything like writing to the local file system, using the registry, and a whole bunch of other stuff. (There are often alternatives, like you could use isolated storage for settings instead of the registry). Or, you can adjust the security to either explicitly trust a specific strong name signed assembly, no matter where is it run from[^] or explicitly allow full trust for apps run from a given network location[^]

    Simon

    A Offline
    A Offline
    AndrusM
    wrote on last edited by
    #3

    If you want your app to automatically just work from a network share you need to design it so it doesn't require full trust I need that in MDI child form Escape key closes form, Ctrl+F1 cycles and Ctrl+F10 toggles maximizing. For this I use code below in form base class which requires full trust. How to implement those features without full trust ? Andrus.

    [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
    protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
    {
    switch (keyData)
    {
    case Keys.Escape:
    if (this != FormManager.MainForm)
    {
    Close();
    return true;
    }
    break;

                case Keys.Control | Keys.F1:
                    for (int i = 0; i < FormManager.MainForm.MdiChildren.Length; i++)
                    {
                        if (FormManager.MainForm.MdiChildren\[i\] == this)
                        {
    
                            if (i < FormManager.MainForm.MdiChildren.Length - 1)
                                FormManager.MainForm.MdiChildren\[i + 1\].Focus();
                            else
                                FormManager.MainForm.MdiChildren\[0\].Focus();
    
                            return true;
                        }
                    }
                    return true;
    
                case Keys.Control | Keys.F10:
                    if (WindowState == FormWindowState.Maximized)
                        WindowState = FormWindowState.Normal;
                    else
                        WindowState = FormWindowState.Maximized;
                    return true;
    
            }
            return base.ProcessCmdKey(ref msg, keyData);
        }
    }
    

    Andrus

    S 1 Reply Last reply
    0
    • A AndrusM

      If you want your app to automatically just work from a network share you need to design it so it doesn't require full trust I need that in MDI child form Escape key closes form, Ctrl+F1 cycles and Ctrl+F10 toggles maximizing. For this I use code below in form base class which requires full trust. How to implement those features without full trust ? Andrus.

      [SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
      protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
      {
      switch (keyData)
      {
      case Keys.Escape:
      if (this != FormManager.MainForm)
      {
      Close();
      return true;
      }
      break;

                  case Keys.Control | Keys.F1:
                      for (int i = 0; i < FormManager.MainForm.MdiChildren.Length; i++)
                      {
                          if (FormManager.MainForm.MdiChildren\[i\] == this)
                          {
      
                              if (i < FormManager.MainForm.MdiChildren.Length - 1)
                                  FormManager.MainForm.MdiChildren\[i + 1\].Focus();
                              else
                                  FormManager.MainForm.MdiChildren\[0\].Focus();
      
                              return true;
                          }
                      }
                      return true;
      
                  case Keys.Control | Keys.F10:
                      if (WindowState == FormWindowState.Maximized)
                          WindowState = FormWindowState.Normal;
                      else
                          WindowState = FormWindowState.Maximized;
                      return true;
      
              }
              return base.ProcessCmdKey(ref msg, keyData);
          }
      }
      

      Andrus

      S Offline
      S Offline
      Simon P Stevens
      wrote on last edited by
      #4

      Handle the forms keypress or keydown events instead of overriding the ProcessCmdKey method. Use code in their to max/min/cycle your forms based on the key pressed.

      Simon

      A 1 Reply Last reply
      0
      • S Simon P Stevens

        Handle the forms keypress or keydown events instead of overriding the ProcessCmdKey method. Use code in their to max/min/cycle your forms based on the key pressed.

        Simon

        A Offline
        A Offline
        AndrusM
        wrote on last edited by
        #5

        http://www.codeproject.com/KB/database/DatabaseAcessWithAdoNet1.aspx[^] states that DataGridView and other controls do not raise those events. How I can use those events when DataGridView is active?

        Andrus

        S 1 Reply Last reply
        0
        • A AndrusM

          http://www.codeproject.com/KB/database/DatabaseAcessWithAdoNet1.aspx[^] states that DataGridView and other controls do not raise those events. How I can use those events when DataGridView is active?

          Andrus

          S Offline
          S Offline
          Simon P Stevens
          wrote on last edited by
          #6

          Ahh...interesting. Have you tried the _forms_ previewkeydown event? (You have to set keypreview to true)

          Simon

          A 1 Reply Last reply
          0
          • S Simon P Stevens

            It's because of the trust level assigned to the app. .net exe files run off of a network share are assigned a low trust level. (As opposed to full trust when run locally). If you want your app to automatically just work from a network share you need to design it so it doesn't require full trust. This means you can't do anything like writing to the local file system, using the registry, and a whole bunch of other stuff. (There are often alternatives, like you could use isolated storage for settings instead of the registry). Or, you can adjust the security to either explicitly trust a specific strong name signed assembly, no matter where is it run from[^] or explicitly allow full trust for apps run from a given network location[^]

            Simon

            A Offline
            A Offline
            AndrusM
            wrote on last edited by
            #7

            I ran with adminstrator rights in Vista CasPol.exe -m -ag 1.2 -url file://z:/myapp/* FullTrust

            C:\...crosoft.NET\Framework\v2.0.50727>g 1.2 -url file://z:/myapp/* FullTrust
            Microsoft (R) .NET Framework CasPol 2.0.50727.1434
            Copyright (c) Microsoft Corporation. All rights reserved.

            The operation you are performing will alter security policy.
            Are you sure you want to perform this operation? (yes/no)
            y
            Added union code group with "-url" membership condition to the Machine level.
            Success

            However z:\myapp\myapp.exe still shows immediately Myapp as stopped working

            Andrus

            S M 2 Replies Last reply
            0
            • A AndrusM

              I ran with adminstrator rights in Vista CasPol.exe -m -ag 1.2 -url file://z:/myapp/* FullTrust

              C:\...crosoft.NET\Framework\v2.0.50727>g 1.2 -url file://z:/myapp/* FullTrust
              Microsoft (R) .NET Framework CasPol 2.0.50727.1434
              Copyright (c) Microsoft Corporation. All rights reserved.

              The operation you are performing will alter security policy.
              Are you sure you want to perform this operation? (yes/no)
              y
              Added union code group with "-url" membership condition to the Machine level.
              Success

              However z:\myapp\myapp.exe still shows immediately Myapp as stopped working

              Andrus

              S Offline
              S Offline
              Simon P Stevens
              wrote on last edited by
              #8

              Sorry, I've no idea about this. Try catching and logging exceptions at the top level to see what's going wrong.

              Simon

              A 1 Reply Last reply
              0
              • S Simon P Stevens

                Ahh...interesting. Have you tried the _forms_ previewkeydown event? (You have to set keypreview to true)

                Simon

                A Offline
                A Offline
                AndrusM
                wrote on last edited by
                #9

                http://blogs.msdn.com/jfoscoding/archive/2005/01/24/359334.aspx[^] States that MDI Parent form ProcessCmdKey is called before PreviewKeyDown. Probably Main form ProcessCmdKey consides those keys as special keys and processec them, it will not pass them to PreviewKeyDown.

                Andrus

                S 1 Reply Last reply
                0
                • S Simon P Stevens

                  Sorry, I've no idea about this. Try catching and logging exceptions at the top level to see what's going wrong.

                  Simon

                  A Offline
                  A Offline
                  AndrusM
                  wrote on last edited by
                  #10

                  Exception which occurs in does not show .NET Winforms unhandled exception dialog. So this exception cannot be catched in .NET code.

                  Andrus

                  1 Reply Last reply
                  0
                  • A AndrusM

                    I ran with adminstrator rights in Vista CasPol.exe -m -ag 1.2 -url file://z:/myapp/* FullTrust

                    C:\...crosoft.NET\Framework\v2.0.50727>g 1.2 -url file://z:/myapp/* FullTrust
                    Microsoft (R) .NET Framework CasPol 2.0.50727.1434
                    Copyright (c) Microsoft Corporation. All rights reserved.

                    The operation you are performing will alter security policy.
                    Are you sure you want to perform this operation? (yes/no)
                    y
                    Added union code group with "-url" membership condition to the Machine level.
                    Success

                    However z:\myapp\myapp.exe still shows immediately Myapp as stopped working

                    Andrus

                    M Offline
                    M Offline
                    mav northwind
                    wrote on last edited by
                    #11

                    Hi! There's a control panel for the configuration of .NET 2.0 if you have the SDK installed. When you select "Runtime security policies" (I hope that's the correct name, I only have the German version here...) you get the option to evaluate a given assembly with respect to all the permissions this assembly is granted. You could test your assembly to verify that the change in your security policy actually affects your application.

                    Regards, mav -- Black holes are the places where God divided by 0...

                    A 1 Reply Last reply
                    0
                    • A AndrusM

                      http://blogs.msdn.com/jfoscoding/archive/2005/01/24/359334.aspx[^] States that MDI Parent form ProcessCmdKey is called before PreviewKeyDown. Probably Main form ProcessCmdKey consides those keys as special keys and processec them, it will not pass them to PreviewKeyDown.

                      Andrus

                      S Offline
                      S Offline
                      Simon P Stevens
                      wrote on last edited by
                      #12

                      Sorry then, I'm out of ideas. There should be a way though. Detecting a key press barely seems like something that should require full trust.

                      Simon

                      A 1 Reply Last reply
                      0
                      • S Simon P Stevens

                        Sorry then, I'm out of ideas. There should be a way though. Detecting a key press barely seems like something that should require full trust.

                        Simon

                        A Offline
                        A Offline
                        AndrusM
                        wrote on last edited by
                        #13

                        No, there are no ways. Detecting those keypresses in winForms requires application to run in full trust mode.

                        Andrus

                        1 Reply Last reply
                        0
                        • M mav northwind

                          Hi! There's a control panel for the configuration of .NET 2.0 if you have the SDK installed. When you select "Runtime security policies" (I hope that's the correct name, I only have the German version here...) you get the option to evaluate a given assembly with respect to all the permissions this assembly is granted. You could test your assembly to verify that the change in your security policy actually affects your application.

                          Regards, mav -- Black holes are the places where God divided by 0...

                          A Offline
                          A Offline
                          AndrusM
                          wrote on last edited by
                          #14

                          .NET 2 SDK downlaod page says that this is obsolete and recommends to download Windows SDK for Windows Server 2008 and .NET Framework 3.5 from http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDC&displaylang=en[^] Whoe package is 1.3 GB to download which is too much. Which options I must select to install security utility ?

                          Andrus

                          M 1 Reply Last reply
                          0
                          • A AndrusM

                            .NET 2 SDK downlaod page says that this is obsolete and recommends to download Windows SDK for Windows Server 2008 and .NET Framework 3.5 from http://www.microsoft.com/downloads/details.aspx?FamilyId=E6E1C3DF-A74F-4207-8586-711EBE331CDC&displaylang=en[^] Whoe package is 1.3 GB to download which is too much. Which options I must select to install security utility ?

                            Andrus

                            M Offline
                            M Offline
                            mav northwind
                            wrote on last edited by
                            #15

                            Don't know, sorry. Don't you have VS2005 installed? In that case, the .NET 2.0 SDK is already installed.

                            Regards, mav -- Black holes are the places where God divided by 0...

                            A 1 Reply Last reply
                            0
                            • M mav northwind

                              Don't know, sorry. Don't you have VS2005 installed? In that case, the .NET 2.0 SDK is already installed.

                              Regards, mav -- Black holes are the places where God divided by 0...

                              A Offline
                              A Offline
                              AndrusM
                              wrote on last edited by
                              #16

                              I have Visual C# Express 2008 Installed. I intalled "SDK Tools" from "Windows and .NET SDK" package but Control Panel does not show this utility. Installer created 2 directories, v6.0a and v6.1 containing files with same names. I tried some executables in v6.1 directory but they appear to do other things.

                              Directory of C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin

                              31.07.2008 12:06 <DIR> .
                              31.07.2008 12:06 <DIR> ..
                              07.11.2007 12:01 72_688 al.exe
                              06.11.2007 21:53 140 al.exe.config
                              16.01.2008 17:21 40_960 apatch.exe
                              07.11.2007 12:01 913_416 aspnet_merge.exe
                              07.11.2007 12:01 58_360 AxImp.exe
                              16.01.2008 17:21 510_976 capicom.dll
                              16.01.2008 17:21 20_992 Cert2Spc.exe
                              16.01.2008 17:21 74_752 CertMgr.Exe
                              16.01.2008 17:21 30_208 checkv4.exe
                              07.11.2007 12:01 66_040 clrver.exe
                              16.01.2008 17:21 23_552 Consume.exe
                              07.11.2007 12:01 185_336 cordbg.exe
                              07.11.2007 12:01 72_192 CorFlags.exe
                              16.01.2008 17:21 60_416 ctrpp.exe
                              19.06.2006 14:09 247 dasmhlp.cnt
                              19.06.2006 14:09 21_963 DASMHLP.HLP
                              22.01.2008 12:11 58_360 disco.exe
                              31.07.2008 12:03 <DIR> en-us
                              07.11.2007 12:01 107_520 FUSLOGVW.exe
                              07.11.2007 12:01 106_496 gacutil.exe
                              06.11.2007 20:07 181 gacutil.exe.config
                              16.01.2008 17:21 132_608 genmanifest.exe
                              07.11.2007 12:01 31_744 guidgen.exe
                              07.11.2007 12:01 386_040 ildasm.exe
                              06.11.2007 20:07 181 ildasm.exe.config
                              11.12.2007 14:15 3_105 INSTLR1.ADM
                              11.12.2007 14:15 9_179 instlr11.adm
                              08.01.2008 17:19 596 isvtier5appsigningprivkey.dat
                              08.01.2008 17:19 148 isvtier5appsigningpubkey.dat
                              08.01.2008 17:19 21_234 isvtier5appsignsdk.cc
                              08.01.2008 17:19 4_916 isvtier5appsignsdk.xml
                              08.01.2008 17:19 56_994 isvtier5appsignsdk_client.xml
                              07.11.2007 12:01 46_064 lc.exe
                              07.11.2007 12:01 78_840 mage.exe
                              07.11.2007 12:01 463_864 mageui.exe
                              16.01.2008 17:21 123_904 make-shell.exe
                              16.01.2008 17:21 30_720 MakeCat.Exe
                              16.01.2008 17:21 57_856 makecert.exe
                              07.11.2007 12:01 111_608 Mdbg.exe
                              22.01.2008 12:11 376_832 MdbgCore.dll
                              22.01.2008 12:11 104_960 MdbgDis.

                              M 1 Reply Last reply
                              0
                              • A AndrusM

                                I have Visual C# Express 2008 Installed. I intalled "SDK Tools" from "Windows and .NET SDK" package but Control Panel does not show this utility. Installer created 2 directories, v6.0a and v6.1 containing files with same names. I tried some executables in v6.1 directory but they appear to do other things.

                                Directory of C:\Program Files\Microsoft SDKs\Windows\v6.1\Bin

                                31.07.2008 12:06 <DIR> .
                                31.07.2008 12:06 <DIR> ..
                                07.11.2007 12:01 72_688 al.exe
                                06.11.2007 21:53 140 al.exe.config
                                16.01.2008 17:21 40_960 apatch.exe
                                07.11.2007 12:01 913_416 aspnet_merge.exe
                                07.11.2007 12:01 58_360 AxImp.exe
                                16.01.2008 17:21 510_976 capicom.dll
                                16.01.2008 17:21 20_992 Cert2Spc.exe
                                16.01.2008 17:21 74_752 CertMgr.Exe
                                16.01.2008 17:21 30_208 checkv4.exe
                                07.11.2007 12:01 66_040 clrver.exe
                                16.01.2008 17:21 23_552 Consume.exe
                                07.11.2007 12:01 185_336 cordbg.exe
                                07.11.2007 12:01 72_192 CorFlags.exe
                                16.01.2008 17:21 60_416 ctrpp.exe
                                19.06.2006 14:09 247 dasmhlp.cnt
                                19.06.2006 14:09 21_963 DASMHLP.HLP
                                22.01.2008 12:11 58_360 disco.exe
                                31.07.2008 12:03 <DIR> en-us
                                07.11.2007 12:01 107_520 FUSLOGVW.exe
                                07.11.2007 12:01 106_496 gacutil.exe
                                06.11.2007 20:07 181 gacutil.exe.config
                                16.01.2008 17:21 132_608 genmanifest.exe
                                07.11.2007 12:01 31_744 guidgen.exe
                                07.11.2007 12:01 386_040 ildasm.exe
                                06.11.2007 20:07 181 ildasm.exe.config
                                11.12.2007 14:15 3_105 INSTLR1.ADM
                                11.12.2007 14:15 9_179 instlr11.adm
                                08.01.2008 17:19 596 isvtier5appsigningprivkey.dat
                                08.01.2008 17:19 148 isvtier5appsigningpubkey.dat
                                08.01.2008 17:19 21_234 isvtier5appsignsdk.cc
                                08.01.2008 17:19 4_916 isvtier5appsignsdk.xml
                                08.01.2008 17:19 56_994 isvtier5appsignsdk_client.xml
                                07.11.2007 12:01 46_064 lc.exe
                                07.11.2007 12:01 78_840 mage.exe
                                07.11.2007 12:01 463_864 mageui.exe
                                16.01.2008 17:21 123_904 make-shell.exe
                                16.01.2008 17:21 30_720 MakeCat.Exe
                                16.01.2008 17:21 57_856 makecert.exe
                                07.11.2007 12:01 111_608 Mdbg.exe
                                22.01.2008 12:11 376_832 MdbgCore.dll
                                22.01.2008 12:11 104_960 MdbgDis.

                                M Offline
                                M Offline
                                mav northwind
                                wrote on last edited by
                                #17

                                I'm afraid I don't know if this control panel is part of VS 2008 Express. With VS 2005 it's located at

                                C:\Programme\Microsoft Visual Studio 8\SDK\v2.0\Bin\mscorcfg.msc

                                Hope this helps...

                                Regards, mav -- Black holes are the places where God divided by 0...

                                A 1 Reply Last reply
                                0
                                • M mav northwind

                                  I'm afraid I don't know if this control panel is part of VS 2008 Express. With VS 2005 it's located at

                                  C:\Programme\Microsoft Visual Studio 8\SDK\v2.0\Bin\mscorcfg.msc

                                  Hope this helps...

                                  Regards, mav -- Black holes are the places where God divided by 0...

                                  A Offline
                                  A Offline
                                  AndrusM
                                  wrote on last edited by
                                  #18

                                  In C# Express 2008 I have folder C:\Program Files\Microsoft Visual Studio 9.0\SDK\v3.5\Bin but this folder is empty. Any idea how to use this tool ?

                                  Andrus

                                  1 Reply Last reply
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Don't have an account? Register

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups