views:

203

answers:

1

HI folks, 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 :

  1. 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.
  2. 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)

  3. 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 : "http://fouad.laplacesoftware.com/". 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

    [...]
}
+2  A: 

Find it!! I've read this post http://stackoverflow.com/questions/2279896/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:"

  (#)if (!NETCF && !NET_4_0)
  //
  // If log4net is strongly named it still allows partially trusted callers
  //
  [assembly: System.Security.AllowPartiallyTrustedCallers]
  (#)endif

It's not good!! You must remove the "!NET_4_0" and replace the [assembly] by this line :

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

Both SMTPAppender and FileAppender now working fine for me!

Simon
Look at that! If it is not my good ol'friend! =)
Will Marcouiller
Hey Will! "ol'friend", not so much, I'm still young you know ;o)
Simon