Computing.Net > Forums > Programming > .VB.NET Security permissions

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

.VB.NET Security permissions

Reply to Message Icon

Original Message
Name: VASS
Date: November 3, 2004 at 19:57:49 Pacific
Subject: .VB.NET Security permissions
OS: WIN XP PRO
CPU/Ram: 1GB
Comment:

Hello everybody. I am having a bit of a problem with VB.NET. I am trying to copy a file from the server to the local PC but i get the following error:

****start of error message ***************
The application attempted to perform an operation not allowed by the security policy <bla bla bla>

Request for the permission of type
System.Security.Permissions.SecurityPermission, mscorlib,
Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 failed.
******* end of error message **************

My code is the following:
*****************************************
Dim SourceFile, DestinationFile As String
Dim test As String
Dim sFileInfo As IO.FileInfo
Dim fileIOPerm1 As FileIOPermission

'fileIOPerm1 = New FileIOPermission(FileIOPermissionAccess.AllAccess, "c:\fileToBeCopied.exe")
'fileIOPerm1.Demand()

Dim f As New FileIOPermission(PermissionState.Unrestricted, "c:\fileToBeCopied.exe")
f.AllLocalFiles = FileIOPermissionAccess.AllAccess


PgbCopying.Minimum = 0
sFileInfo = New System.IO.FileInfo("j:\fileToBeCopied.exe") 'j is the server
test = sFileInfo.Length
PgbCopying.Maximum = test
SourceFile = "j:\fileToBeCopied.exe" ' Define source file name.
DestinationFile = "c:\fileToBeCopied" ' Define target file name.
FileCopy(SourceFile, DestinationFile) ' Copy source to target.
PgbCopying.Value = PgbCopying.Value + test
Timer1.Enabled = False
End

****** END OF CODE ****************
So i am trying to copy the FileToBeCopied from the J Drive to the C Drive, and while in my computer all are OK, when i go to another one i get this message. At first I used the demand command with the same result. Then i comment it out and tryed PermitionState. Nothing.Any help? Thank you...



Report Offensive Message For Removal


Response Number 1
Name: Chi Happens
Date: November 4, 2004 at 06:31:06 Pacific
Reply: (edit)

I don't know if it is a programming issue. It might be that the computer where you get the error does not have those permissions on the target computer.

Are you logged into the network on the computer using an account that has those permissions on the target computer?

You might want to check the permissions on the source and target drives and folders.

I hope this helps some.

Chi

"They mostly come at night...mostly"


Report Offensive Follow Up For Removal

Response Number 2
Name: VASS
Date: November 4, 2004 at 19:09:43 Pacific
Reply: (edit)

Hello Chi,

I gave full permissions to the user for the directory where the file is, but still nothing. If I use VB6 I don't have that problem.

The user is logging in as "User" and not as "Administrator" as I do. Is that has anything to do with that? Like I said I have given him full rights.

Thank you for your reply. I am still trying to find a solution...


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge
Poll History




Data Recovery Software