473,624 Members | 2,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SecurityExcepti on in Console Application on GetCommandLineA rgs()

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
SecurityExcepti on on the following line:

Dim args() As String = Environment.Get CommandLineArgs ()

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 .SecurityExcept ion
System.Security .SecurityExcept ion: Request for the permission of type
System.Security .Permissions.En vironmentPermis sion, mscorlib,
Version=1.0.330 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9
failed.
at System.Security .CodeAccessSecu rityEngine.Chec kHelper(Permiss ionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermi ssion demand,
PermissionToken permToken)
at System.Security .CodeAccessSecu rityEngine.Chec k(PermissionTok en
permToken, CodeAccessPermi ssion demand, StackCrawlMark& stackMark,
Int32 checkFrames, Int32 unrestrictedOve rride)
at System.Security .CodeAccessSecu rityEngine.Chec k(CodeAccessPer mission
cap, StackCrawlMark& stackMark)
at System.Security .CodeAccessPerm ission.Demand()
at System.Environm ent.GetCommandL ineArgs()
at VerifyFolder.Mo dule1.Main() in C:\Documents and
Settings\jwgoer lich\My Documents\Visua l Studio
Projects\Verify Folder\Module1. vb:line 12
Nov 20 '05 #1
2 4218
Dim args() As String = Environment.Get CommandLineArgs ()

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 SecurityExcepti on 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\Adminis trators 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 .SecurityExcept ion
System.Security .SecurityExcept ion: Request for the permission of type
System.Security .Permissions.Fi leIOPermission, mscorlib,
Version=1.0.330 0.0, Culture=neutral , PublicKeyToken= b77a5c561934e08 9
failed.
at System.Security .CodeAccessSecu rityEngine.Chec kHelper(Permiss ionSet
grantedSet, PermissionSet deniedSet, CodeAccessPermi ssion demand,
PermissionToken permToken)
at System.Security .CodeAccessSecu rityEngine.Chec k(PermissionTok en
permToken, CodeAccessPermi ssion demand, StackCrawlMark& stackMark,
Int32 checkFrames, Int32 unrestrictedOve rride)
at System.Security .CodeAccessSecu rityEngine.Chec k(CodeAccessPer mission
cap, StackCrawlMark& stackMark)
at System.Security .CodeAccessPerm ission.Demand()
at System.IO.Direc tory.InternalCr eateDirectory(S tring fullPath,
String path)
at System.IO.Direc tory.CreateDire ctory(String path)
at VerifyFolder.Mo dule1.Main(Stri ng[] args)
Nov 20 '05 #3

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

Similar topics

9
2358
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 even work. The application never gets started far enough to get into any of my resource usage (which is several FileIOPermission's). I do not have any assembly level Permissions defined, and all of my FileIOPermission usages are imperative. ...
17
4211
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 console using System.Console.WriteLine if thge project has its "Output Type" to "Windows Application". However I can write to stdio if i set output type to "Console Application". When I do this I unfortunately get a "console box" as well
7
2881
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 testing by manually starting the app from the server, that is logging into the server, and running). This app depending on available resources (txt, xml data files), starts simple exe console apps which load simple data feeds into an SQL db. In...
9
7836
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 'Main' method with an appropriate signature was found" Anyone have an idea what I need to do to fix this? Thanks! Full code follows:
3
4584
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 its value. In .NET 1.1 this worked fine, however under .NET 2.0 it fails when I am not an administrator on the remote server. To provide a lean demonstration of the issue, I created the following class: ============================
3
2092
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 that the command line args is only capturing the last file selected when the app is executed. files.length is always equal to 2 no matter how many files are selected when the app is run. Is there another way to do this? Module Module1 Sub...
11
5268
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
8302
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 by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. Exception Details: for the permission of type
4
1706
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 completed project/library sample of that pls? Regards
0
8246
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8631
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8341
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4184
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1489
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.