CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2000
    Location
    KS
    Posts
    6

    Question Run a C# .exe program from a shared network drive/directory

    I'm having trouble finding information to help me understand what I need to include in a C# program (see below along with the resulting error message) in order to make it so that it can be run from a shared network location on each of my client workstations. I can run the program locally of course. I'm sure it has to do with security permissions in the .NET Framework, but I'm having very little success in understanding how this needs to work.

    Do I include the following code (or a modification thereof)?
    --------------------------------------------------------------------------
    using System.Security;
    using System.Security.Permissions;

    [assembly:UIPermissionAttribute(SecurityAction.RequestMinimum, Unrestricted=true)]
    [assembly:FileIOPermissionAttribute(SecurityAction.RequestMinimum, All="C:\\")]
    --------------------------------------------------------------------------

    Hep me, please!!!


    Here is the code to this very basic console app:

    Code:
    =====
    using System;
    using System.IO;

    namespace ConsoleApplication1
    {
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class Class1
    {
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main(string[] args)
    {
    //
    FileInfo fileInfo = new FileInfo(@"C:\temp\test.txt");
    string FileDir = fileInfo.DirectoryName;

    Console.WriteLine(FileDir);
    //
    }
    }
    }



    Error Msg is:
    =========
    Unhandled Exception: System.Security.Policy.PolicyException: Required permissions cannot be acquired

  2. #2
    Join Date
    Jun 2002
    Location
    Philadelphia, PA
    Posts
    85
    What user is it running as? If you're running it as a user which does not have read/write access to the network drive that could do it. Is it running as a domain user?

  3. #3
    Join Date
    Jan 2000
    Location
    KS
    Posts
    6
    Actually, it has to do with .NET security rather than Windows security. If you look at Start/Programs/Administrative Tools/Microsoft .NET Framework Configuration (or the .NET Framework Wizards) you'll probably see what I'm talking about. I've received many replies on this topic on a couple of other forums. I'll direct you to this one since it seems to have a majority of the information collected together. I'm still undecided as to which way I will go in handling this. For now, I've simply opened up the security ("local intranet") settings in the .NET Framework Wizards all the way on the client machine so that the source .exe on the server directory can be run. Here is the link to one of the other forums I mentioned:

    http://www.csharphelp.com/board2/rea...=14849&t=14849

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

Featured