Results 1 to 4 of 4

Thread: OpenFileDialog not populating textbox problem.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Chicagoland
    Posts
    92

    OpenFileDialog not populating textbox problem.

    I'm puttint a program on my work's intranet that I would like everyone in my group to use. However I am running into a problem that doesn't seem to make sense.

    The way it is supposed to work is that you click a browse button and it opens a OpenFileDialog box. You select the file you want and click on open. The path is then displayed in the textbox. Here is my code:
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
    3.             Try
    4.                 TextBox1.Text = OpenFileDialog1.FileName
    5.             Catch ex As Exception
    6.                 Console.WriteLine("The file cannot be read")
    7.                 Console.WriteLine(ex.Message)
    8.             End Try
    9.         End If
    10.     End Sub

    As long as the application is on my hard drive, it works fine. When I put the .exe on the network, the textbox stays blank.

    So I tried another thing.
    VB Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.         OpenFileDialog1.ShowDialog()
    3.          TextBox1.Text = OpenFileDialog1.FileName
    4.     End Sub

    Again, this works fine on my hard drive. When I put the .exe on the network, I get this error message:
    The application attempted to perform an operation not allowed by the security policy. The operation required the SecuriyException. To grant this application the required permission please contact your system administrator, or use the Microsoft .NET security policy administration tool.

    If you click Continue, the application will ignore this error and attempt to continue. If you click Quit, the application will be shut down immediately.

    Request for the permission of type
    System.Security.Permissions.FileIOPermission, mscorlib,
    PublicKeyToken=b77a5c561934e089 failed.
    I have full control priveledges on this network drive. Any ideas on what gives?

  2. #2
    Addicted Member
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    252
    Hi,

    Suppose that your EXE is in Computer #1 and you are trying to access the EXE from Computer #2 which is networked.
    Go to Computer #2.
    Start > Control Panel > Administrative Tools > Microsoft .NET Framework 1.1 Wizards.
    Click Trust an Assembly
    Follow the prompts and browse for the EXE which is in Computer #1.
    Give full rights to the application.
    You are done.

    Cheers,
    McoreD.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2003
    Location
    Chicagoland
    Posts
    92
    I wish it were that easy. The network drive that I put the exe on is controlled by our network admin group. They are not to happy about stuff like that.

    Is there anyway to set the rights prgrammatically?

  4. #4
    Addicted Member
    Join Date
    Apr 2003
    Location
    Australia
    Posts
    252
    Well, you can go one step futhur by setting:

    Start > Control Panel > Administrative Tools > Microsoft .NET Framework 1.1 Wizards.
    Adjust .NET Security > Next > Local Intranet > Full Trust

    This way, you will have to do it only once for every computer.

    P.S: If it could have been done programmatically, then that would be overriding the security settings set by the target computer, hence a security threat. So I don't think that can be easily.
    Last edited by ~*McoreD*~; Feb 25th, 2004 at 11:00 PM.

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