unhandled SecurityException in Visual Basic 2005 Express

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to read in a text file using code that I copied and pasted from
the MS help file.

Using Reader As New _
Microsoft.VisualBasic.FileIO.TextFieldParser("c:\bankcheck")

At this line I get "Request for the permission of type
'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."

I've tried researching this in the help files and on the web but, I must
confess, that what I've found has only confused me more.

The file DOES exist and I have full permissions to it. What am I doing wrong
and how can I fix it?

Thanks for you help.
Ken
 
Ken,

I tried your command and cannot get any error. Your file description looks
strange to me, are you sure it exist and is a text file?

Cor
 
KenEisman said:
At this line I get "Request for the permission of type
'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
The file DOES exist and I have full permissions to it.

/You/ might have, but your /code/ doesn't.
Code Access Security, part of the .Net Framework, does away with all
that "you have to run it under this account for it to work" nonsense.
Every program runs in a security "sandbox" (although the "LocalZone" one
is /pretty/ big!).

Are you running this code from a network file share? Something like

\\server\share\...\myprogram.exe

If so, your program runs in a /much/ smaller "sandbox" - by default, the
Framework doesn't distinguish between your network share and
www.DodgyAndDangerousSoftware.com (apologies to anyone who actually owns
a site of this name!)

Read up on the CASPOL (command line) utility or find the "Microsoft .Net
Framework ?.? Configuration" program (GUI) in your PC's Administative
Tools.

HTH,
Phill W.
 
Back
Top