Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB.NET 1.0 > VB.NET 2002/2003 Basics
|
VB.NET 2002/2003 Basics For coders who are new to Visual Basic, working in .NET versions 2002 or 2003 (1.0 and 1.1).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB.NET 2002/2003 Basics 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 October 8th, 2004, 02:00 PM
Registered User
 
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jshae
Default System.Security.Permissions.SecurityPermission

I am a newbie programmer, trying to do something with shell functionality to open up a file or application. My boss has it in a number of his applications, and it seems straight forward, but I keep getting this exception. One site says you need to have service pack 1.1, which I already do.

I started with this, based on my boss's code:
Shell("notepad.exe", AppWinStyle.NormalFocus, True)

I looked around and found this, but it still does not work:
System.Diagnostics.Process.Start("notepad.exe")

Any help would be appreciated.
Jesica
 
Old October 8th, 2004, 02:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Are you getting an error? If so, what is it.

System.Diagnostics.Process.Start("notepad.exe")

works for me.

J
 
Old October 8th, 2004, 03:10 PM
Registered User
 
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jshae
Default

Hi J,
This is the error I get.

System.Security.SecurityException: Request for the permission of type System.Security.Permissions.SecurityPermission, mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
   at System.Security.CodeAccessSecurityEngine.CheckToke nBasedSetHelper(Boolean ignoreGrants, TokenBasedSet grants, TokenBasedSet denied, TokenBasedSet demands)
   at System.Security.CodeAccessSecurityEngine.CheckSetH elper(PermissionSet grants, PermissionSet denied, PermissionSet demands)
   at Microsoft.VisualBasic.Interaction.Shell(String Pathname, AppWinStyle Style, Boolean Wait, Int32 Timeout)
   at _13F_Report.Form1.OpenNP() in \\file3\Home\jshae\My Documents\Visual Studio Projects\13F Report\Form1.vb:line 125


I've tried many different ways of doing it, but always get the same error:
ATTEMPT 1:
Shell("C:\Windows\System32\Notepad.exe", AppWinStyle.NormalFocus, True)

ATTEMPT 2:
Process.Start("notepad.exe")

ATTEMPT 3:
System.Diagnostics.Process.Start("notepad.exe")

ATTEMPT 4:
Dim MyProcess As New ProcessStartInfo("notepad.exe") MyProcess.WindowStyle = ProcessWindowStyle.Normal
Process.Start(MyProcess)

ATTEMPT 5:
Dim sinfo1 As System.Diagnostics.ProcessStartInfo = Nothing
sinfo1 = New System.Diagnostics.ProcessStartInfo("notepad.exe")
System.Diagnostics.Process.Start(sinfo1)
 
Old October 9th, 2004, 12:11 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

Well, I am going to shoot for the obvious and say that security is the problem and not your code. Judging from this:

\\file3\Home\jshae\My Documents\Visual Studio Projects\13F Report\Form1

it looks like you are running this project on a network share. Network shares are not fully trusted so the code doesn't execute normally. Try copying your project to your local machine and see if it works.

---------------------------------------------------------------
System.Diagnostics.Process.Start("notepad.exe")
---------------------------------------------------------------

should work.

J
 
Old October 11th, 2004, 10:05 AM
Registered User
 
Join Date: Oct 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jshae
Default

You're right. It works fine on my machine at home. Simple!
Thanks.

 
Old October 11th, 2004, 11:20 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

You welcome. :)

J
 
Old November 4th, 2004, 02:16 AM
Registered User
 
Join Date: Nov 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok i know it works if u run it off a network but what if u want to run it on a network. how can i fix it so that it is trusted and runs over a network?






Similar Threads
Thread Thread Starter Forum Replies Last Post
Permissions on DB without user-level security nbourre Access VBA 4 June 7th, 2008 08:09 AM
System.Security.SecurityException: Security error coolcatjk Pro VB.NET 2002/2003 4 March 2nd, 2006 06:00 PM
Security permissions of file eelisMX Pro VB.NET 2002/2003 0 October 4th, 2005 05:33 AM
Security = System.mdw ?? martinaccess Access 5 November 13th, 2004 11:45 AM
File System Object Permissions kilika Classic ASP Basics 2 August 6th, 2003 09:23 AM





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