Windows form application - run from network

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • alag20
    New Member
    • Apr 2007
    • 84

    #1

    Windows form application - run from network

    Hi,
    I have a winform application which I have developed using c# .Net 2. This simply deletes a text file and creates a new empty file!

    This works fine on the local machine but as soon as I place this on the network and try and run it from that location, it gives me a Application attempted to perform an operation not allowed by security policy.

    *************** *************** *************** *********
    System.Security .SecurityExcept ion: That assembly does not allow partially trusted callers.
    at System.Security .CodeAccessSecu rityEngine.Thro wSecurityExcept ion(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHa ndle rmh, SecurityAction action, Object demand, IPermission permThatFailed)

    *************** *************** *************** *********


    Can someone please help what to do as searching on the internet only yields solution for web .net applications and nothing for windows form on network!
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    On the computer that you wish to run it on (not the server that houses the application) you will need to go to admin tools and open up the .NET2.0 configuration.
    Then you either need to attempt to supply security allowances directly to the specific application, or just blanket lower your security settings for local network files.

    Comment

    • alag20
      New Member
      • Apr 2007
      • 84

      #3
      Originally posted by Plater
      On the computer that you wish to run it on (not the server that houses the application) you will need to go to admin tools and open up the .NET2.0 configuration.
      Then you either need to attempt to supply security allowances directly to the specific application, or just blanket lower your security settings for local network files.
      How do I add security allowance directly to specific application / blanket lower my settings?

      Also is there anyways, how we can do this from the backend so that the user is not prompted! I would like to ideally do this on the fly without telling the user!

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        Unless your network is run on a strict domain (in which case you might be able to set some domain policy on .NET security) you will have to do it for each user.

        The directions are right there when you open up the configuration tool.
        For .NET2.0 I think they need the SDK installed to have the tool.
        You *might* be able to get away with just copying the .exe over and running the tool that way.

        Comment

        • alag20
          New Member
          • Apr 2007
          • 84

          #5
          Originally posted by Plater
          Unless your network is run on a strict domain (in which case you might be able to set some domain policy on .NET security) you will have to do it for each user.

          The directions are right there when you open up the configuration tool.
          For .NET2.0 I think they need the SDK installed to have the tool.
          You *might* be able to get away with just copying the .exe over and running the tool that way.
          This is a windows application. This error only occurs when the exe is located on network drive rather than local. Often copying this wont be an option!

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            Right.
            I said to try to copy the .net2.0 configuration tool over if they don't already have it.
            They will probably have the .net1.1 configuration tool, but it didn't seem to effect program that used .NET2.0 correctly.

            Comment

            • alag20
              New Member
              • Apr 2007
              • 84

              #7
              Originally posted by Plater
              Right.
              I said to try to copy the .net2.0 configuration tool over if they don't already have it.
              They will probably have the .net1.1 configuration tool, but it didn't seem to effect program that used .NET2.0 correctly.
              Thanks but people may not want to copy or change permissions there!

              Comment

              • Plater
                Recognized Expert Expert
                • Apr 2007
                • 7872

                #8
                I was just looking it up, as my company is in a similar boat.
                I knew I had done something in school about requesting permissions at run time and I found this:


                If you access a file in your custom assembly, you must add the following code to your custom assembly before you access the file:

                FileIOPermissio n filePerm = new FileIOPermissio n(FileIOPermiss ionAccess.Read, "C:\TestFil e");
                filePerm.Assert ();
                I believe there are similar permission objects that you can assert() as well.

                There is also some kind of assembler-type derivate that uses the [ ] brackets I believe. (Like the way you can use [DLLImport])

                Comment

                • alag20
                  New Member
                  • Apr 2007
                  • 84

                  #9
                  Added strong name to assembly. Added caspol to batch to allow permissions!

                  Job done! Thanks for your help guys!

                  Comment

                  Working...