473,322 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

SecurityException in Console Application on GetCommandLineArgs()

I wrote a simple VB.Net console application. It accepts command line
parameters and creates a folder structure. It works on the local file
system without a problem

If I run the console app from a UNC or network share, I get a
SecurityException on the following line:

Dim args() As String = Environment.GetCommandLineArgs()

Has anyone seen this before? Is there something special I need to do
for console applications on UNC paths?

Thanks in advance,
J Wolfgang Goerlich
Here is the complete exception text:

System.Security.SecurityException
System.Security.SecurityException: Request for the permission of type
System.Security.Permissions.EnvironmentPermission, mscorlib,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
failed.
at System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(Per missionToken
permToken, CodeAccessPermission demand, StackCrawlMark& stackMark,
Int32 checkFrames, Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission
cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at System.Environment.GetCommandLineArgs()
at VerifyFolder.Module1.Main() in C:\Documents and
Settings\jwgoerlich\My Documents\Visual Studio
Projects\VerifyFolder\Module1.vb:line 12
Nov 20 '05 #1
2 4187
Dim args() As String = Environment.GetCommandLineArgs()

Has anyone seen this before? Is there something special I need to do
for console applications on UNC paths?


I suggest you get the command line args as parameters to your Main
method instead:

Shared Sub Main(ByVal CmdArgs() As String)

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 20 '05 #2
> Shared Sub Main(ByVal CmdArgs() As String)

Thank you, Mattias. While I cannot create sub main as shared in the
Console module, your solution works otherwise. That is one big step
forward.

The next problem is that I am getting a SecurityException when I go to
access the remote file system. I am going over a UNC path using the
domain Administrator account. I have verified that this account is a
member of the BUILTIN\Administrators on the computer I am accessing,
and that it has full share and NTFS rights. My console app works if I
copy it to that computer and run it locally. Unfortunately, I must run
it over UNC.

Can you give me some pointers on this one, too? Do .Net console
applications typically not perform well over UNC?

J Wolfgang Goerlich
Here is the complete exception text:

System.Security.SecurityException
System.Security.SecurityException: Request for the permission of type
System.Security.Permissions.FileIOPermission, mscorlib,
Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
failed.
at System.Security.CodeAccessSecurityEngine.CheckHelp er(PermissionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermission demand,
PermissionToken permToken)
at System.Security.CodeAccessSecurityEngine.Check(Per missionToken
permToken, CodeAccessPermission demand, StackCrawlMark& stackMark,
Int32 checkFrames, Int32 unrestrictedOverride)
at System.Security.CodeAccessSecurityEngine.Check(Cod eAccessPermission
cap, StackCrawlMark& stackMark)
at System.Security.CodeAccessPermission.Demand()
at System.IO.Directory.InternalCreateDirectory(String fullPath,
String path)
at System.IO.Directory.CreateDirectory(String path)
at VerifyFolder.Module1.Main(String[] args)
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: James | last post by:
I have created a console application in C# that appears to not even really get started unless the code group in which it is contained is set to FullTrusted. The Everything permission set does not...
17
by: MumboJumbo | last post by:
Hi I have a really basic question hopefully some can help me with: Can you write a (i.e. one) C# project that works from the cmd line and gui? I seems if i write a GUI app it can't write to...
7
by: Phil Mc | last post by:
Hi all I have a small scheduling application that I have written which will be running on a Windows 2003 server. This application is started at different times by an 'autosys' job (though I am...
9
by: TechN00b | last post by:
I'm trying to write a quick commandline app that takes a string from the commandline and returns a formatted md5 hash. Unfortunately the code won't comple and returns an error of "No accessible...
3
by: Geoff McElhanon | last post by:
I have been struggling with a security issue that occurs under .NET 2.0, but does not occur under .NET 1.1. Essentially I am trying to open up a performance counter on a remote server and monitor...
3
by: =?Utf-8?B?VGltIEE=?= | last post by:
I want the user to be able to select a group of files in windows explorer, right click, open with - my application and have my application put all of the file names onto the clipboard. It seems...
11
by: =?Utf-8?B?U2VyZ2lv?= | last post by:
I need to pass two parameter to a vb.net 2003 windows form application, is this posible? how?
5
by: Henry Stock | last post by:
I am trying to understand the following error: Any thing you can tell me about this is appreciated. Security Exception Description: The application attempted to perform an operation not allowed...
4
by: Kee | last post by:
Dear All I need a sample working under console using C#, basically it should looks like utilities under console support pipe and redirect operation. May I seek your help to send me a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.