UnitTest: Type is not resolved for member 'log4net.Util.PropertiesDictionary

I am using log4net as logging framework in the projects I am working on. Every thing seems fine untill I used the LogicalThreadContext of log4net. During the unit tests I received this message:

An exception occurred while invoking executor 'executor://mstestadapter/v1': Type is not resolved for member 'log4net.Util.PropertiesDictionary,log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a'

What's happening here? Well my code look something like this:

    public class CreateLogRequestId: ActionFilterAttribute
    {
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            log4net.LogicalThreadContext.Properties["requestid"] = Guid.NewGuid();
        }
    }

This Action filter add's a Guid to every request which can be used during logging like so:

    <appender name="EventLogAppender" type="log4net.Appender.EventLogAppender">
      <applicationName value="MyApplicationName" />
      <eventId value="1" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date %-5level [%property{requestid}] %logger - %message%newline" />
      </layout>
      <threshold value="ERROR" />
    </appender>

In the conversionPattern the %property{requestid} gets filled with the value that is set during the requests.
Note: in my project I use different values, but this is just for the example.

I think it's super nice to use features like this to add some more logic to the logging. 

But when I created unit tests for the ActionFilterAttribute above the unit test will fail with the exception.

Apparently this can be fixed with the following code in your unit tests class that uses the LogicalThreadContext.

        [TestCleanup]
        public void Cleanup()
        {
            CallContext.FreeNamedDataSlot("log4net.Util.LogicalThreadContextProperties");
        }

Happy coding ;-).