473,320 Members | 1,920 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,320 software developers and data experts.

Unhandled SecurityException

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.

The exact error message is:

Unhandled Exception: System.Security.SecurityException: Request failed.
at MyApp.Main(String[] args)
Additional information: Request failed.

I am running this from the command-line, not from the IDE.
--
James

Oct 24 '05 #1
9 2325
I did a little further testing and developed a small console application that
reproduces the problem:

using System;
using System.Diagnostics;

namespace Class1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
// Set of required command-line options
class Tes123
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
System.Diagnostics.FileVersionInfo versionInfo =
FileVersionInfo.GetVersionInfo("%systemroot%\\Note pad.exe");
Console.WriteLine(versionInfo.FileVersion);

}
}
}

If you comment out the GetVersionInfoLine (and place something else in the
WriteLine statement), you do not get the originally stated exception.
--
James

"James" wrote:
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.

The exact error message is:

Unhandled Exception: System.Security.SecurityException: Request failed.
at MyApp.Main(String[] args)
Additional information: Request failed.

I am running this from the command-line, not from the IDE.
--
James

Oct 24 '05 #2
Hi James,

Thanks for your repro code. I tested it on my machine, however, it gave me
a FileNotFound exception. I made some changes to your code, and it works
fine on my machine.

string s = Environment.GetEnvironmentVariable("systemroot");
System.Diagnostics.FileVersionInfo versionInfo =
FileVersionInfo.GetVersionInfo(s + "\\Notepad.exe");
Console.WriteLine(versionInfo.FileVersion);

I think there might be some incorrect settings on you machine. I suggest
you try to use Microsoft .NET Framework 1.1 Configuration to check for the
required permission set for your assembly. Here are the steps:

1. Open Microsoft .NET Framework 1.1 Configuration in Administrative Tools.
2. In the left tree, select Runtime Security Policy.
3. Click Evaluate assembly from the right pane.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Oct 25 '05 #3
I left off the most important detail. The application runs as long as the
assembly is unsigned, or is delay-signed. Once I "fully" sign this app, it
produces the error mentioned in my original message.
--
James

"Kevin Yu [MSFT]" wrote:
Hi James,

Thanks for your repro code. I tested it on my machine, however, it gave me
a FileNotFound exception. I made some changes to your code, and it works
fine on my machine.

string s = Environment.GetEnvironmentVariable("systemroot");
System.Diagnostics.FileVersionInfo versionInfo =
FileVersionInfo.GetVersionInfo(s + "\\Notepad.exe");
Console.WriteLine(versionInfo.FileVersion);

I think there might be some incorrect settings on you machine. I suggest
you try to use Microsoft .NET Framework 1.1 Configuration to check for the
required permission set for your assembly. Here are the steps:

1. Open Microsoft .NET Framework 1.1 Configuration in Administrative Tools.
2. In the left tree, select Runtime Security Policy.
3. Click Evaluate assembly from the right pane.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Oct 25 '05 #4
And making sure I give every detail this time...

After signing the assembly, I create a code group in the .NET Configuration
Tool under the User node, that uses Strong Name as the evidence. It is in
this code group that I have to set FullTrust (vs. everything, or some subset)
to get the app to run.
--
James

"James" wrote:
I left off the most important detail. The application runs as long as the
assembly is unsigned, or is delay-signed. Once I "fully" sign this app, it
produces the error mentioned in my original message.
--
James

"Kevin Yu [MSFT]" wrote:
Hi James,

Thanks for your repro code. I tested it on my machine, however, it gave me
a FileNotFound exception. I made some changes to your code, and it works
fine on my machine.

string s = Environment.GetEnvironmentVariable("systemroot");
System.Diagnostics.FileVersionInfo versionInfo =
FileVersionInfo.GetVersionInfo(s + "\\Notepad.exe");
Console.WriteLine(versionInfo.FileVersion);

I think there might be some incorrect settings on you machine. I suggest
you try to use Microsoft .NET Framework 1.1 Configuration to check for the
required permission set for your assembly. Here are the steps:

1. Open Microsoft .NET Framework 1.1 Configuration in Administrative Tools.
2. In the left tree, select Runtime Security Policy.
3. Click Evaluate assembly from the right pane.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Oct 25 '05 #5
Hi James,

I followed your steps to add a new code group and assigned FullTrust or
Everything permission set to this code group. However, your code still
works fine on my machine. Have you tried to reproduce this with another
clean machine?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Oct 26 '05 #6
Same on every machine I've tried. I did notice in the documentation for the
FileVersionInfo class that there is a LinkDemand requiring full trust: (see
note on
http://msdn2.microsoft.com/en-us/lib...ileversioninfo)
--
James

"Kevin Yu [MSFT]" wrote:
Hi James,

I followed your steps to add a new code group and assigned FullTrust or
Everything permission set to this code group. However, your code still
works fine on my machine. Have you tried to reproduce this with another
clean machine?

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Oct 26 '05 #7
Hi James,

It seems that the .NET framework 2.0 requres full trust. I was testing on
the .NET framework 1.1.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Oct 27 '05 #8
I am testing with the 1.1 Framework. I have the code group for the assembly
set to Exclusive ("this policy level will only have the permissions from the
permission set associated with this code group"). If I don't set that
property the assembly maintains Unrestricted trust and still runs.
--
James

"Kevin Yu [MSFT]" wrote:
Hi James,

It seems that the .NET framework 2.0 requres full trust. I was testing on
the .NET framework 1.1.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Oct 27 '05 #9
Hi James,

Thanks for noticing me of checking this option. Now finally, I get this
issue reproed. Based on my research, the FileVersionInfo class requires
full trusted permission on the machine. If you use a .NET reflector to
check this class definition, you'll see the following attribute before the
definition.

[PermissionSet(SecurityAction.LinkDemand, Unrestricted=true)]

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Oct 28 '05 #10

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

Similar topics

2
by: MFRASER | last post by:
I am getting a System.Security.SecurityException when I try and laod a dataset from an xml file any ideas on what would cause this? System.Security.SecurityException' occurred in mscorlib.dll ...
2
by: jwgoerlich | last post by:
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...
5
by: Dave Stewart | last post by:
I recently wrote my first Vb.net application, or at least my first complex app since moving up from vb6. When run from the VS.NET IDE, the program shows no errors and runs fine. When the output exe...
7
by: Sabo, Eric | last post by:
We are an educational environment, we are using VB .Net and Windows XP SP2. The users are power users. We have a Visual Basic .Net class that is having trouble with their project, they are getting...
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...
0
by: Seok Bee | last post by:
Dear Experts, I've created a Console application to perform a checking of an Excel file. During development using vb.net in Visual Studio 2005, the application is running fine. I can get my...
0
by: John | last post by:
I write a simple .NET client program that calls Java Web Services. Unfortunately, when it runs, it has error "unhandled exception of type 'System.Security.SecurityException' occured in...
5
by: Ankit Aneja | last post by:
This is my problem. I am using Visual 2003, .Net framework 1.1 and the Application Block I configured the DAAB using the Enterprise Library Configuration now this is the error which is coming ...
3
by: jtnpham | last post by:
This is code I created to add a record where the user inputs the new text in textboxes: Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click City =...
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...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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)...
0
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...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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

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.