log4net的和.NET 4.0 RC [英] Log4Net and .NET 4.0 RC

查看:183
本文介绍了log4net的和.NET 4.0 RC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译项目依赖于使用.NET 4.0 RC的log4net的日志框架,并遇到了一些问题。

I tried to compile a project dependent on the Log4Net logging framework using .NET 4.0 RC and ran into some problems.

开箱即用的(只是改变目标到.NET 4.0),它不再有效,安全异常。

Out of the box (just changing the target to .NET 4.0), it no longer works, a security exception is thrown.

继承安全规则违反   而重写成员:   'log4net.Util.ReadOnlyPropertiesDictionary.GetObjectData(System.Runtime.Serialization.SerializationInfo,   System.Runtime.Serialization.StreamingContext)。   的安全访问   压倒一切的方法必须符合   该方法的安全访问   为

Inheritance security rules violated while overriding member: 'log4net.Util.ReadOnlyPropertiesDictionary.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being

这是通过添加以下行来log4net的组件(在AssemblyInfo.cs中)解决:

This was resolved by adding the following line to the log4net assembly(in AssemblyInfo.cs):

[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]

有人可以解释为什么这是必需的,是否有替代品做这种方式?难道这涉及到如何log4net的是写还是其他什么东西?

Can someone explain why this is required and are there alternatives to doing it this way? Is this related to how Log4Net is written or something else?

推荐答案

这是必需的,因为.NET 4.0中加入的 2级安全透明code (这是新的默认值),并废除了的 $ C C接入安全 $。 1级安全透明code 是仍然存在的兼容性但是,当你发现,已被指定。

This is required because .NET 4.0 added Level 2 Security-Transparent Code (which is the new default) and did away with Code Access Security. Level 1 Security-Transparent Code is still there for compatibility but, as you found, has to be specified.

您是正确的,它关系到如何log4net的写入。 真的是没有替代品,你发现除了更新log4net的code中的解决方案 - 或切换到不同的记录解决方案:)

You are correct that it is related to how Log4Net is written. There really is no alternative to the solution you found other than to update the Log4Net code - or switch to a different logging solution :)

这篇关于log4net的和.NET 4.0 RC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆