logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lars Nellemann Nielsen (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4NET-398) SerializationException after setting a LogicalThreadContext property
Date Wed, 24 Jun 2015 08:13:42 GMT

    [ https://issues.apache.org/jira/browse/LOG4NET-398?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14599053#comment-14599053
] 

Lars Nellemann Nielsen commented on LOG4NET-398:
------------------------------------------------

We have run into the same problem and can replicate the issue on sites running in IIS and
a console application acting as a host for multiple other console applications, separated
in appDomains. So both rely on separate appDomains. 

The issue goes away when not setting log4net.LogicalThreadContext.Properties

LogicalThreadContext is implemented using System.Runtime.Remoting.Messaging.CallContex, and
stores the data in log4net.Util.PropertiesDictionary which inherits log4net.Util.ReadOnlyPropertiesDictionary

making [log4net.Util.ReadOnlyPropertiesDictionary|http://svn.apache.org/viewvc/logging/log4net/trunk/src/log4net/Util/ReadOnlyPropertiesDictionary.cs?view=markup]
inherit [MarshalByRefObject|https://msdn.microsoft.com/en-us/library/system.marshalbyrefobject%28v=vs.110%29.aspx]
fixes the issue.

Its obvious that the properties dictionary cannot cross into the other appdomain, since inheriting
MarshalByRefObject fixes it. I cannot see why installing log4net into the GAC fixes the problem
as well, perhaps someone can shed some light on this?

Can anyone confirm the fix?

> SerializationException after setting a LogicalThreadContext property
> --------------------------------------------------------------------
>
>                 Key: LOG4NET-398
>                 URL: https://issues.apache.org/jira/browse/LOG4NET-398
>             Project: Log4net
>          Issue Type: Task
>          Components: Core
>    Affects Versions: 1.2.12
>         Environment: Visual Studio 2010
>            Reporter: Thomas Meum
>            Priority: Minor
>              Labels: triaged
>
> I have found that accessing Page.Request.Url after setting a LogicalThreadContext property
causes a SerializationException with the following message: Type is not resolved for member
'log4net.Util.PropertiesDictionary,log4net, Version=1.2.12.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a'.
> I have been able to reproduce the problem on two different machines with the following
steps:
> 1. Create a new ASP.NET Empty Web Application
> 2. Add a reference to log4net.dll
> 3. Add a new Web Form
> 4. Add the following code to Page_Load:
>     log4net.LogicalThreadContext.Properties["Test"] = 1;
>     Uri url = Request.Url;
> 5. Hit F5



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message