[prev in list] [next in list] [prev in thread] [next in thread] 

List:       log4net-user
Subject:    ASP .NET 2.0 Security error - Config problems - Any ideas?
From:       "Daniel Miller" <daniel.miller () corp ! idt ! net>
Date:       2006-06-29 6:50:28
Message-ID: 003601c69b48$4f5c7dd0$6d32990a () ME ! IDTCORP ! NET
[Download RAW message or body]

Hi there

 

I'm using log4net with an ASP .NET 2.0 application. On my local machine all
works well, but when deployed to an ISP, there are no logs.

 

After much debugging, I discovered that log4net was failing on a "Security
Error" (see error message below) - i.e., the server's trust level is Medium
and blocks log4net from reading the config data. (When I used a separate
log4net.config file this error was swallowed; it only showed up when I moved
the config data to web.config).

 

After much searching online, still no hope in sight (the trust level cannot
be overridden for this server) and some claim there is no solution.

(See
http://www.tisgoud.nl/blog/CommentView,guid,79cd746e-556a-4417-a1fe-fb429bd3
7f80.aspx)

 

Any ideas? Suggestions? 

 

I've tried loading configuration data from Global.asax (using
XmlConfigurator.Configure(),XmlConfigurator. ConfigureAndWatch(.), and the
same for DOMConfigurator) and also using AssemblyInfo.cs ([assembly:
log4net.Config.XmlConfigurator(ConfigFile="log4net.config",Watch=true )]),
you name it.

 

Thanks in advance. 

 

Daniel

 

---

Error message:

 

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: Request for the
permission of type 'System.Configuration.ConfigurationPermission,
System.Configuration, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' failed.

 

Source Error: 

 

An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.  

 

Stack Trace: 

 

 

[SecurityException: Request for the permission of type
'System.Configuration.ConfigurationPermission, System.Configuration,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.]

   System.Security.CodeAccessSecurityEngine.Check(Object demand,
StackCrawlMark& stackMark, Boolean isPermSet) +0

   System.Security.CodeAccessPermission.Demand() +59

 
System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String
configKey, Boolean requirePermission, Boolean isTrustedWithoutAptca) +65

 

 

 

 

----------------------------------------------------------------------------
----

Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
Version:2.0.50727.42


[Attachment #3 (text/html)]

<html xmlns:o="urn:schemas-microsoft-com:office:office" \
xmlns:w="urn:schemas-microsoft-com:office:word" \
xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 11 (filtered medium)">
<style>
<!--
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	margin-bottom:.0001pt;
	text-align:right;
	direction:rtl;
	unicode-bidi:embed;
	font-size:12.0pt;
	font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal;
	font-family:Arial;
	color:windowtext;}
span.EmailStyle18
	{mso-style-type:personal-reply;
	font-family:Arial;
	color:navy;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
	{page:Section1;}
-->
</style>

</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1 dir=RTL>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 color=navy face=Arial><span style='font-size:10.0pt;
font-family:Arial;color:navy'>H</span></font><font size=2 face=Arial><span
style='font-size:10.0pt;font-family:Arial'>i there<o:p></o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span \
style='font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>I'm
using log4net with an ASP .NET 2.0 application. On my local machine all works
well, but when deployed to an ISP, there are no logs.<o:p></o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span \
style='font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>After
much debugging, I discovered that log4net was failing on a &quot;Security
Error&quot; (see error message below) &#8211; i.e., the server's trust level is
Medium and blocks log4net from reading the config data. (When I used a separate
log4net.config file this error was swallowed; it only showed up when I moved
the config data to web.config).<o:p></o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span \
style='font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>After
much searching online, still no hope in sight (the trust level cannot be
overridden for this server) and some claim there is no \
solution.<o:p></o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>(See
<a
href="http://www.tisgoud.nl/blog/CommentView,guid,79cd746e-556a-4417-a1fe-fb429bd37f80 \
.aspx">http://www.tisgoud.nl/blog/CommentView,guid,79cd746e-556a-4417-a1fe-fb429bd37f80.aspx</a>)<o:p></o:p></span></font></p>


<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span \
style='font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>Any
ideas? Suggestions? <o:p></o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span \
style='font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span style='font-size:10.0pt;font-family:Arial'>I've
tried loading configuration data from Global.asax (using </span></font><font
size=2 color=teal face="Courier New"><span style='font-size:10.0pt;font-family:
"Courier New";color:teal'>XmlConfigurator</span></font><font size=2
face="Courier New"><span style='font-size:10.0pt;font-family:"Courier \
New"'>.Configure(),<font color=teal><span \
style='color:teal'>XmlConfigurator</span></font>.<font color=green><span \
style='color:green'> ConfigureAndWatch</span></font></span></font><font size=2 \
face=Arial><span style='font-size:10.0pt;font-family:Arial'>(&#8230;), and the same \
for </span></font><font size=2 color=teal face="Courier New"><span \
style='font-size:10.0pt;font-family:"Courier \
New";color:teal'>DOMConfigurator</span></font><font size=2 face=Arial><span \
style='font-size:10.0pt;font-family:Arial'>) and also using AssemblyInfo.cs \
(</span></font><font size=2 face="Courier New"><span \
style='font-size:10.0pt;font-family:"Courier New"'>[assembly: \
log4net.Config.XmlConfigurator(ConfigFile=&quot;log4net.config&quot;,Watch=true \
)]</span></font><font size=2 face=Arial><span style='font-size:10.0pt; \
font-family:Arial'>), you name it.<o:p></o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span \
style='font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span \
style='font-size:10.0pt;font-family:Arial'>Thanks in advance. \
<o:p></o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span \
style='font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=2 face=Arial><span \
style='font-size:10.0pt;font-family:Arial'>Daniel<o:p></o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span \
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span \
style='font-size:12.0pt'>---<o:p></o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Error
message:<o:p></o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span \
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Security
Exception <o:p></o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span \
style='font-size:12.0pt'>Description: The application attempted to perform an \
operation not allowed by the security policy.&nbsp; To grant this application the \
required permission please contact your system administrator or change the \
application's trust level in the configuration file. </span></font><span lang=HE \
dir=RTL><o:p></o:p></span></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span lang=HE dir=RTL
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Exception
Details: System.Security.SecurityException: Request for the permission of type
'System.Configuration.ConfigurationPermission, System.Configuration,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' \
failed.</span></font><span lang=HE dir=RTL><o:p></o:p></span></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span lang=HE dir=RTL
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Source
Error: </span></font><span lang=HE dir=RTL><o:p></o:p></span></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span lang=HE dir=RTL
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>An
unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can be
identified using the exception stack trace below.&nbsp; </span></font><span
lang=HE dir=RTL><o:p></o:p></span></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span lang=HE dir=RTL
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Stack
Trace: </span></font><span lang=HE dir=RTL><o:p></o:p></span></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span lang=HE dir=RTL
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span lang=HE dir=RTL
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><span dir=LTR></span><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'><span dir=LTR></span>[SecurityException: Request for
the permission of type 'System.Configuration.ConfigurationPermission,
System.Configuration, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' failed.]</span></font><span lang=HE \
dir=RTL><o:p></o:p></span></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><span dir=LTR></span><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'><span dir=LTR></span>&nbsp;&nbsp; \
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark&amp; \
stackMark, Boolean isPermSet) +0</span></font><span lang=HE \
dir=RTL><o:p></o:p></span></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><span dir=LTR></span><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'><span dir=LTR></span>&nbsp;&nbsp;
System.Security.CodeAccessPermission.Demand() +59</span></font><span lang=HE
dir=RTL><o:p></o:p></span></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><span dir=LTR></span><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'><span dir=LTR></span>&nbsp;&nbsp;
System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String configKey,
Boolean requirePermission, Boolean isTrustedWithoutAptca) +65</span></font><span
lang=HE dir=RTL><o:p></o:p></span></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span lang=HE dir=RTL
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><span dir=LTR></span><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'><span dir=LTR></span>&nbsp;</span></font><span
lang=HE dir=RTL><o:p></o:p></span></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span lang=HE dir=RTL
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span lang=HE dir=RTL
style='font-size:12.0pt'><o:p>&nbsp;</o:p></span></font></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><span dir=LTR></span><font size=3 face="Times New Roman"><span
style='font-size:12.0pt'><span \
dir=LTR></span>--------------------------------------------------------------------------------</span></font><span
 lang=HE dir=RTL><o:p></o:p></span></p>

<p class=MsoNormal dir=LTR style='text-align:left;direction:ltr;unicode-bidi:
embed'><font size=3 face="Times New Roman"><span style='font-size:12.0pt'>Version
Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET
Version:2.0.50727.42</span></font><span lang=HE dir=RTL><o:p></o:p></span></p>

</div>

</body>

</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic