Wrox Programmer Forums
|
BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6
This is the forum to discuss the Wrox book Beginning Visual Basic 2005 by Thearon Willis, Bryan Newsome; ISBN: 9780764574016
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 7th, 2007, 02:13 PM
Registered User
 
Join Date: Feb 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Security Error on the "Try It Out" from p.113

When compiling and testing (Start debugging) the "Try It Out" for Ch 4 on pg. 113 I get the following errors:

Error from compiling:
A first chance exception of type 'System.Security.SecurityException' occurred in mscorlib.dll

Error from clicking on button:
! SecurityException was unhandled
Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I tried the suggested ACTION of granting the project permission, but alas it was to no avail.

I've pasted the exception detail below my sig.

I'm running VS 05 with SP1 and all the latest updates (incl IE 7) XP Pro SP2 also with the latest updates.

NOTE: My project is running off a network drive, I don't know if that makes a dif?

My Code:
Code:
    Private Sub btnForEachLoop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnForEachLoop.Click

        'List each folder at the root of your C drive using a For Each...Next Loop
        For Each strFolder As String In My.Computer.FileSystem.GetDirectories("C:\")
            'Add the directory to the list
            lstData.Items.Add(strFolder)
        Next

    End Sub


Thanks,
Tek



Exception Detail Noted Below:
System.Security.SecurityException was unhandled
  Message="Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
  Source="mscorlib"
  StackTrace:
       at System.Security.CodeAccessSecurityEngine.Check(Obj ect demand, StackCrawlMark& stackMark, Boolean isPermSet)
       at System.Security.CodeAccessPermission.Demand()
       at System.IO.Path.GetFullPath(String path)
       at Microsoft.VisualBasic.FileIO.FileSystem.FindFilesO rDirectories(FileOrDirectory FileOrDirectory, String directory, SearchOption searchType, String[] wildcards, Collection`1 Results)
       at Microsoft.VisualBasic.MyServices.FileSystemProxy.G etDirectories(String directory)
       at Loops.Form1.btnForEachLoop_Click(Object sender, EventArgs e)
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventAr gs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallba ck(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchM essageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager. System.Windows.Forms.UnsafeNativeMethods.IMsoCompo nentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.Run MessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.Run MessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationCo ntext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsF ormsApplicationBase.Run(String[] commandLine)
       at Loops.My.MyApplication.Main(String[] Args)
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.Run UsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context( Object state)
       at System.Threading.ExecutionContext.runTryCode(Objec t userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.Exe cuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(Exec utionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
 
Old February 7th, 2007, 03:05 PM
Registered User
 
Join Date: Feb 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

OK OK! I get it, do ALL my testing BEFORE posting ;-D

I dragged my exe file out of the debug folder on my network drive onto my desktop and it worked fine, so the issue must have been the fact it was running from the network drive, something to note for future projects.

Now the question is how does an end user grant an application with my.computer access permission to run when the app is on a network server (itra or internet)?

I'm probably getting way ahead of myself here, but I have already done a good chunk of Access programming and anticipate getting up to speed on VB for VS 05 quickly, and security is an important issue. Maybe someone can recommend a good VB security book/site etc..


Thanks,
Tek





Similar Threads
Thread Thread Starter Forum Replies Last Post
Security Exception Error nici ASP.NET 2.0 Basics 0 May 23rd, 2007 12:03 PM
Security error reggie213 ASP.NET 1.0 and 1.1 Basics 0 April 6th, 2006 07:56 AM
System.Security.SecurityException: Security error coolcatjk Pro VB.NET 2002/2003 4 March 2nd, 2006 06:00 PM
ThePhile 113 Build Errors eureka BOOK: ASP.NET Website Programming Problem-Design-Solution 4 September 27th, 2005 01:39 PM
EntryToLog.aspx -- security error reidcor ASP.NET 1.0 and 1.1 Basics 3 July 24th, 2003 05:05 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.