Quantcast
Channel: NLog - Advanced .NET Logging
Viewing all articles
Browse latest Browse all 60

Closed Issue: Tweak for Full Trust : variant of No Log File, SecurityException, Partial Trust [6400]

$
0
0
<p>The issue of SecurityException, while using in partial trust environment - web application, is raised at two points.</p>
<p>&nbsp;</p>
<p>To resolve the Partial Trust error, modify the AssemblyCofig.cs file of NLog project and add following</p>
<p>[Code]</p>
<p>//System.Security.SecurityException: That assembly does not allow partially trusted callers.</p>
<p>[assembly: System.Security.AllowPartiallyTrustedCallers()]</p>
<p>[/Code]</p>
<p>Also make sure the project properties has the Signature assigned.</p>
<p>&nbsp;</p>
<p>After doing the above workaround, you will face following issues, that causes no file issue, securityexception etc. [The issue of not supporting Partial Trust is known issue and noted in release note.]</p>
<p>&nbsp;</p>
<p>1] while accessing the nlog.config : XmlLoggingConfiguration.AppConfig : access to System.Configuration.ConfigurationManager</p>
<p>Work around : use web.config</p>
<p>&nbsp;</p>
<p>2] while loading configuration from web.config and creating a FileSystemWatcher internally.</p>
<p>Work around following code change</p>
<p>File: LogFactory.cs</p>
<p>Line 164 </p>
<p>[Code]</p>
<p>if (this.config != null)</p>
<p>{</p>
<p> Dump(this.config);</p>
<p> if (AppDomain.CurrentDomain.IsFullyTrusted)</p>
<p> {</p>
<p> this.watcher.Watch(this.config.FileNamesToWatch);</p>
<p> }</p>
<p>}</p>
<p>[/Code]</p>
<p>&nbsp;</p>
<p>Hope this helps team and community.</p>

Comments:

Moved to https://github.com/NLog/NLog/issues/144


Viewing all articles
Browse latest Browse all 60

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>