Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSCORLIB.DLL - 'System.Security.SecurityException' 2

Status
Not open for further replies.

pfildes

Programmer
Jun 17, 2004
54
GB
I'm new to VB.NET and have come across a sample application which resembles a basic file explorer. Having opened the project, when I run it I get a message stating;

An unhandled exception of type 'System.Security.SecurityException' occurred in mscorlib.dll
Additional information: Request for the permission of type System.Security.Permissions.SecurityPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.


The program breaks at the following line;
Code:
Dim Drives() As String
 -> Drives = System.IO.Directory.GetLogicalDrives()

Can anybody please tell me what is wrong?.[ponder]

I have .NET Framework 1.1 installed.
 
Are you running it off a network drive? .NET has different security rules when you're not running off a local drive.

Also, the MSDN docs say you'll get this if you don't have the SecurityPermissionFlag.UnmanagedCode value (scroll down to the bottom of Directory.GetLogicalDrives().

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Yes, I'm developing on a network drive.

Paul
 
Open your control panel -> Admin Tools -> .Net Wizards -> Trust Assembly -> follow wizard steps to trust you assembly.

Note that if you trust an assembly you may have to re-trust it each time it's strong name changes. If you are going to develope on a network share you may want to raise the Intranet Zone trust level.

-Rick

VB.Net Forum forum796 forum855 ASP.NET Forum
[monkey]I believe in killer coding ninja monkeys.[monkey]
 
Try applying this attribute to your class or property:
Code:
<System.Security.Permissions.PermissionSetAttribute(System.Security.Permissions.SecurityAction.Demand, Name:="FullTrust")> _
I'm not sure whether it will help or not but its worth a try. Good Luck!


Have a great day!

j2consulting@yahoo.com
 
I am now developing on my local drive so I no longer have the problem, however when I come to developing on a network drive I have a couple of solutions.

Thanks to ThatRickGuy, chiph & SBendBuckeye for their help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top