Error message while running app

Talk2Tom11

Centurion
Joined
Feb 22, 2004
Messages
144
Location
Westchester, NY
Why trying to run an application on my pc i am getting an error message that says that the application does not have permission to do what it wants to do. here are two pictures of the error messages.

screen1.bmp


screen2.bmp


The errors are not happening on the computer in which i wrote the program on. Just another computer that is running the program...

this is my code:

Form 1:
Visual Basic:
 Imports System.IO
Imports System.Security.permissions 

Private Function ParseFile( _
 ByVal fileName As String) _
 As Hashtable

        Try
            Dim data As TextData
            Dim table As New Hashtable
            Dim reader As New StreamReader(fileName)
            Dim text As String = reader.ReadToEnd()

            Dim words() As String = _
             text.Split(" ,.()[]{}".ToCharArray)

            For Each word As String In words
                If table.Contains(word) Then

                    data = DirectCast(table(word), TextData)
                    data.Count += 1
                Else
                    data = New TextData(word)
                    table.Add(word, data)
                End If
            Next
            Return table
        Catch eexp As Exception
            MsgBox("Please Choose a Readable File Joe")
        End Try
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim file As String
        file = TextBox1.Text
        Dim table As Hashtable = _
 ParseFile(file)
        Try
            For Each de As DictionaryEntry In table
                With ListBox1.Items
                    .Add(de.Value.ToString())
                End With
                'Debug.WriteLine(de.Value.ToString())
                'MsgBox(de.Value.ToString())
            Next
        Catch ex As Exception
        End Try
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ofd1.ShowDialog()

        TextBox1.Text = ofd1.FileName
    End Sub

Class TextData:

Visual Basic:
Public Class TextData
    Public Value As String
    Public Count As Integer

    Public Sub New(ByVal Value As String)
        Me.Value = Value
        Me.Count = 1
    End Sub

    Public Overrides Function GetHashCode() _
     As Integer
        Return Value.GetHashCode()
    End Function

    Public Overrides Function ToString() As String
        Return Me.Value & ":" & Me.Count
    End Function
End Class
 
Last edited:
They aren't errors, there is nothing wrong with the program that wasn't already wrong when you ran it on your own machine. Applications are granted security permissions to access resources and take actions based on things like their location who signed them and whether they are known to be from trusted sources or not. In thise case the person running your application is doing so in a way which means that the application is running as a limited trust app.

Typically this is because people who are unaware of security are running them directly from the web or from a mapped shared drive. The quick fix is to move the application to a local drive which will cause it to run in full trust. The better but more difficult fix is to work out what permissions your application needs and declare the minimum permissions require by your application which will prevent it being run if those permissions can't be granted.

From the small amount of the exception message i can see i'd say its failing on:
Code:
            Dim reader As New StreamReader(fileName)
 
Back
Top