Return-Path: X-Original-To: apmail-logging-log4net-dev-archive@www.apache.org Delivered-To: apmail-logging-log4net-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E7ACCF6FE for ; Tue, 1 Oct 2013 15:00:32 +0000 (UTC) Received: (qmail 59947 invoked by uid 500); 1 Oct 2013 15:00:32 -0000 Delivered-To: apmail-logging-log4net-dev-archive@logging.apache.org Received: (qmail 59903 invoked by uid 500); 1 Oct 2013 15:00:32 -0000 Mailing-List: contact log4net-dev-help@logging.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Log4NET Dev" List-Id: Delivered-To: mailing list log4net-dev@logging.apache.org Received: (qmail 59758 invoked by uid 99); 1 Oct 2013 15:00:31 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Oct 2013 15:00:31 +0000 Date: Tue, 1 Oct 2013 15:00:31 +0000 (UTC) From: "W.R. Dittmer (JIRA)" To: log4net-dev@logging.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (LOG4NET-393) Using dynamic methods with log4net causes NullReferenceException in StackFrameItem MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LOG4NET-393?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] W.R. Dittmer updated LOG4NET-393: --------------------------------- Description: In our production code we use dynamic methods e.g. when using the factory pattern. We upgraded from 1.2.10 to 1.2.12 and encountered the following exception: log4net:ERROR An exception ocurred while retreiving stack frame information. System.NullReferenceException: Object reference not set to an instance of an object. at log4net.Core.StackFrameItem..ctor(StackFrame frame) in c:\Users\wilfred.dittmer\Documents\Visual Studio 2012\Projects\Log4netLambaExpressionTest\log4net-1.2.12-src\log4net-1.2.12\src\Core\StackFrameItem.cs:line 61 I created a test project (attached) which shows the exception occuring. If the method is: {System.Object lambda_method(System.Runtime.CompilerServices.Closure)} then one cannot access the DeclaringType. The code then tries to get the FullName of the null value which causes the exception. According to: http://msdn.microsoft.com/en-us/library/system.reflection.emit.dynamicmethod.declaringtype.aspx "DynamicMethod.DeclaringType: Gets the type that declares the method, which is always null for dynamic methods." So it seems best to check if DeclaringType is null and if so leave the m_className set to 'NA'. was: In our production code we use dynamic methods e.g. when using the factory pattern. We upgraded from 1.2.10 to 1.2.12 and encountered the following exception: log4net:ERROR An exception ocurred while retreiving stack frame information. System.NullReferenceException: Object reference not set to an instance of an object. at log4net.Core.StackFrameItem..ctor(StackFrame frame) in c:\Users\wilfred.dittmer\Documents\Visual Studio 2012\Projects\Log4netLambaExpressionTest\log4net-1.2.12-src\log4net-1.2.12\src\Core\StackFrameItem.cs:line 61 I created a test project (attached) which shows the exception occuring. If the the method is: {System.Object lambda_method(System.Runtime.CompilerServices.Closure)} then one cannot access the DeclaringType. The code then tries to get the FullName of the null value which causes the exception. According to: http://msdn.microsoft.com/en-us/library/system.reflection.emit.dynamicmethod.declaringtype.aspx "DynamicMethod.DeclaringType: Gets the type that declares the method, which is always null for dynamic methods." So it seems best to check if DeclaringType is null and if so leave the m_className set to 'NA'. > Using dynamic methods with log4net causes NullReferenceException in StackFrameItem > ---------------------------------------------------------------------------------- > > Key: LOG4NET-393 > URL: https://issues.apache.org/jira/browse/LOG4NET-393 > Project: Log4net > Issue Type: Bug > Components: Core > Affects Versions: 1.2.12 > Environment: VS2012, Windows 7 > Reporter: W.R. Dittmer > Assignee: Dominik Psenner > Priority: Blocker > Fix For: 1.2.13 > > Attachments: Log4netLambaExpressionTest.zip > > > In our production code we use dynamic methods e.g. when using the factory pattern. We upgraded from 1.2.10 to 1.2.12 and encountered the following exception: > log4net:ERROR An exception ocurred while retreiving stack frame information. > System.NullReferenceException: Object reference not set to an instance of an object. > at log4net.Core.StackFrameItem..ctor(StackFrame frame) in c:\Users\wilfred.dittmer\Documents\Visual Studio 2012\Projects\Log4netLambaExpressionTest\log4net-1.2.12-src\log4net-1.2.12\src\Core\StackFrameItem.cs:line 61 > I created a test project (attached) which shows the exception occuring. > If the method is: {System.Object lambda_method(System.Runtime.CompilerServices.Closure)} > then one cannot access the DeclaringType. The code then tries to get the FullName of the null value which causes the exception. > According to: http://msdn.microsoft.com/en-us/library/system.reflection.emit.dynamicmethod.declaringtype.aspx > "DynamicMethod.DeclaringType: Gets the type that declares the method, which is always null for dynamic methods." > So it seems best to check if DeclaringType is null and if so leave the m_className set to 'NA'. -- This message was sent by Atlassian JIRA (v6.1#6144)