Talk2Tom11 Posted June 2, 2006 Posted June 2, 2006 (edited) 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. http://knuth.mville.edu/~dodsont/joe/counter/screen1.bmp http://knuth.mville.edu/~dodsont/joe/counter/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: 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: 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 Edited June 2, 2006 by Talk2Tom11 Quote
Wraith Posted June 3, 2006 Posted June 3, 2006 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: Dim reader As New StreamReader(fileName) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.