Sim*_*gré 2 c# asp.net log4net .net-4.0
我看到网上有很多很多关于这个的帖子,也是在stackoverflow中,但是我找不到任何方法来解决我的问题.我现在已经尝试了3件事,但这一切都没有用:
所以,我从网上搜索,发现它可能与log4net.dll编译的版本有关.哪个是奇怪的但是无论如何,我遇到了一个错误,它要求我为程序集生成一个强密钥,这就是我所做的和编译所以我发布这个项目并获取log4net.dll并将其添加到我的projet的引用.结果:尝试从Global.asax行进行配置时没有编译错误,但出现1错误:
protected void Application_Start(object sender, EventArgs e) {
log4net.Config.XmlConfigurator.Configure();
}
Run Code Online (Sandbox Code Playgroud)
这是错误:(见#Ref1)
有没有人成功使用Framework 4.0将SmtpAppender配置为C#VS.net Web应用程序?
覆盖成员时违反了继承安全规则:'log4net.Util.ReadOnlyPropertiesDictionary.GetObjectData(System.Runtime.Serialization.SerializationInfo,System.Runtime.Serialization.StreamingContext)'.覆盖方法的安全性可访问性必须与被覆盖的方法的安全性可访问性相匹配
我刚试过别的东西.我打开了使用VS.net 2010转换的log4net应用程序的完整.sln,添加了一个与我的应用程序完全相同的Web项目,但在这种情况下,我可以调试Log4net库.这是它失败的地方:
// If we could not find an alias
if (rep == null)
{
LogLog.Debug("DefaultRepositorySelector: Creating repository [" + repositoryName + "] using type [" + repositoryType + "]");
// Call the no arg constructor for the repositoryType
HERE -> rep = (ILoggerRepository)Activator.CreateInstance(repositoryType); <-- HERE
[...]
}
Run Code Online (Sandbox Code Playgroud)
找到它!!我已经阅读了这篇文章Log4Net和.NET 4.0 RC,它只是解决它!
在我的第一篇文章(问题)中,在我试过的第3步,它说要替换AssemblyInfo.cs中的东西:
他说:"在AssemblyInfo.cs中,将部分安全性的部分修改为:"
(#)if (!NETCF && !NET_4_0)
//
// If log4net is strongly named it still allows partially trusted callers
//
[assembly: System.Security.AllowPartiallyTrustedCallers]
(#)endif
Run Code Online (Sandbox Code Playgroud)
这不好!!您必须删除"!NET_4_0"并用此行替换[assembly]:
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]
Run Code Online (Sandbox Code Playgroud)
SMTPAppender和FileAppender现在都适合我!
归档时间: |
|
查看次数: |
4792 次 |
最近记录: |