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

Security policy problem

I'm in the process of getting to grips with ASP .Net, and have run into
a problem without an obvious solution. I've added some C# code to write
errors to the event log, and that compiles fine. But when run, the
application doesn't have permission to access the registry, and a
security exception is raised.

Now I know that the answer lies somewhere in the .NET configuration
panel, but I've no idea where. I've tried a few things, but got lost in
the Byzantine complexity of security policy and trust levels, and
nothing's worked so far.

One problem is that I can't find the assembly file for my application -
I've read that it's supposed to be in a \bin folder somewhere near the
..Net framework stuff, but I can find no such folder.

Be really grateful if any guru here can help.

Environment is Windows XP Pro with IIS 5.1 and .Net Framework 1.1 SP1.
I'm using Web Matrix to compile the C# code.

Debugger output below - exception is on line 33,
myEventLog.WriteEntry(..)

Many thanks for any ideas,

Chris

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: System.Security.SecurityException: Requested registry
access is not allowed.

Source Error:

Line 31: EventLog myEventLog = new EventLog("Application");
Line 32: myEventLog.Source="BANDCh03";
Line 33: myEventLog.WriteEntry(ex.ToString(),
EventLogEntryType.Error);
Nov 18 '05 #1
2 1503
"Chris Bazalgette" <ch***@cbaz.demon.co.uk> wrote in message
news:n9**************@cbaz.demon.co.uk...
I'm in the process of getting to grips with ASP .Net, and have run into
a problem without an obvious solution. I've added some C# code to write
errors to the event log, and that compiles fine. But when run, the
application doesn't have permission to access the registry, and a
security exception is raised.


The typical problem is that the ASPNET account doesn't have the privileges
necessary to create a new event source. If you create the event source
first, you should have no trouble writing to it from your web application.

What I usually do, using VS.NET, is to drag an EventLog component onto a
design surface (maybe onto global.asax opened in design mode). I then
configure the event log and source I want. Next, I right-click and choose
"Add Installer". This creates an event log installer capable of installing
that event log.

I then delete the EventLog I dragged onto the design surface!

When built into mywebsite.dll, I can then use "installutil" to "install" the
site:

cd bin
installutil -i mywebsite.dll

When I run these commands as an administrator, the event log source gets
created. Then, when I run my web site, it can create log entries all it
likes.
--
John Saunders
johnwsaundersiii at hotmail
Nov 18 '05 #2
John,

Thanks a lot for replying - that gives me some useful ideas to play
with.

- Chris
In message <#$**************@TK2MSFTNGP14.phx.gbl>, John Saunders
<jo**************@notcoldmail.com> writes
"Chris Bazalgette" <ch***@cbaz.demon.co.uk> wrote in message
news:n9**************@cbaz.demon.co.uk...
I'm in the process of getting to grips with ASP .Net, and have run into
a problem without an obvious solution. I've added some C# code to write
errors to the event log, and that compiles fine. But when run, the
application doesn't have permission to access the registry, and a
security exception is raised.


The typical problem is that the ASPNET account doesn't have the privileges
necessary to create a new event source. If you create the event source
first, you should have no trouble writing to it from your web application.

What I usually do, using VS.NET, is to drag an EventLog component onto a
design surface (maybe onto global.asax opened in design mode). I then
configure the event log and source I want. Next, I right-click and choose
"Add Installer". This creates an event log installer capable of installing
that event log.

[...]
Nov 18 '05 #3

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

Similar topics

4
by: Lorenzo | last post by:
hi you all, first of all apologies for having cross-posted this message but really i did not know where to post it. please let me know what ng you consider the most suitable for the described...
2
by: Ioannis Demetriades | last post by:
Hi, I created a shortcut to a .NET application that is located on a different workstation but when I try to execute the app (through the shortcut) I get an message saying "The application...
12
by: Mark | last post by:
Hello, in a simple console application I try to create a file with some code like: FileStream file = new FileStream("test.txt", FileMode.OpenOrCreate, FileAccess.Write); StreamWriter sw = new...
0
by: Namratha Shah \(Nasha\) | last post by:
Hey Guys, Today we are going to look at Code Access Security. Code access security is a feature of .NET that manages code depending on its trust level. If the CLS trusts the code enough to...
16
by: Marina | last post by:
Hi, I am trying to find the minimum security settings to allow a windows control embedded in IE have full trust. If I give the entire Intranet zone full trust, this works. However, this is...
11
by: David W. Simmonds | last post by:
I have a form that will prompt for a user name/password. In VS.NET, I have the protected form in a folder named Admin. I have a Web.config file in that folder as well. It contains the following...
5
by: Norsoft | last post by:
I have a .Net 1.1 application which is downloaded into an aspx page. It is a dll which inherits from System.Windows.Forms.UserControl. It works fine on a PC with only the 1.1 Framework. However,...
2
by: John Kotuby | last post by:
Hello all, Note: This is the full version of a Post that I inadvertently sent before it was complete. About a year ago I wrote a VB.NET 2003 solution that consists of a number of assemblies...
1
by: WebServiceSecurity | last post by:
The issue involves the following technologies: - 1. .NET 2.0 Framework 2. WSE2.0 (WS-Security) 3. X.509 certificates 4. BEA Weblogic 8.1.5
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...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.