logging-log4net-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Bodewig (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4NET-398) SerializationException after setting a LogicalThreadContext property
Date Sat, 19 Dec 2015 17:57:46 GMT

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

Stefan Bodewig commented on LOG4NET-398:

I'm not sure I've got much to add, in particular I unfortunately haven't got an environment
to debug the problem.

But I have got a theory. I think the exception is raised once control is returning from the
child process to the parent process. AFAIU when the child application is executed it is on
the same thread as the parent. The child then sets a CallContext property and when it is done
the logical thread context tries to preserve the properties set on the call context when the
thread returns to the parent application - and there it cannot get deserialized becuase the
log4net classes are unknown.

This is a change we've introduced with 1.2.12 by fixing LOG4NET-317 where we made sure the
properties really travel with the CallContext - and it now may travel into directions where
you don't want them to go.

You may want to add call to {{Clear}} as the last step in Child to see whether Parent still
fails (it doesn't even start on my Linux box).

Implementing MarshalByRefObject removes the need of deserializing the properties (and this
of having the class available in Parent).

This may mean that code that is run inside a separate AppDomain via some kind of hosting environment
should clean up the LogicalThreadContext before returning.  I haven't got any clear idea how
to enforce that code-wise.

> 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
>         Attachments: log4net.zip
> 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=, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a'.
> I have been able to reproduce the problem on two different machines with the following
> 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

View raw message