Home All Groups Group Topic Archive Search About

unhandled SecurityException in Visual Basic 2005 Express

Author
19 Jul 2006 11:09 PM
KenEisman
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

Author
20 Jul 2006 2:05 AM
Cor Ligthert [MVP]
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

Show quoteHide quote
"KenEisman" <KenEis***@discussions.microsoft.com> schreef in bericht
news:23CD5082-BCD9-48E1-8D5A-62EC3AB051F8@microsoft.com...
> 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
>
Author
20 Jul 2006 1:21 PM
Phill W.
KenEisman wrote:

> 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.