I saw that there’s many, many thread about this on the web, also in stackoverflow, but i didn’t find any way to resolve my problem. I’ve tried 3 things about now and it all didn’t works :
- I’ve simply tried to get the log4net.dll whos given from the log4net zip folder with all source code in the bin directory. Results : No compilation error, but my SmtpAppender just don’t send errors email.
-
So, I’ve search from web to find that it can be related to the version that the log4net.dll were compile. Which is wierd but anyway, I ran into one error whos asking me to generate a strong key for the assembly and that’s what I’ve done and compile so I release this project and take the log4net.dll and add it to my projet’s refereces. Result : No compilation error but 1 error when it is trying to configure from the Global.asax line :
protected void Application_Start(object sender, EventArgs e) { log4net.Config.XmlConfigurator.Configure(); }Here’s the error : (See #Ref1)
- So, again, I’ve found out this thread from a certain Ahmed Fouad whos, according to me, were looking to works fine. Here’s the thread. I’ve done everything he says but I still run into the same error (#Ref1).
Do anyone succeeded to configure SmtpAppender into a C# VS.net Web Appplication using Framework 4.0 ?
Ref1
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 overriden
Additional informations (Review #1)
I’ve just tried something else. I’ve open the complete .sln of the log4net application converted with VS.net 2010, added a web project looking exactly the same as my application but in this case, I’m able to debug Log4net library. Here’s where it fails :
// 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
[...]
}
Find it!! I’ve read this post Log4Net and .NET 4.0 RC and it simply just solve it!
In my first post (the question), at step 3 of things i’ve tried, it says to replace something in AssemblyInfo.cs :
He says : “In AssemblyInfo.cs, modified the part for Partial Security to be like this:”
It’s not good!! You must remove the “!NET_4_0” and replace the [assembly] by this line :
Both SMTPAppender and FileAppender now working fine for me!