Castle Windsor NLog Integration dll versioning problem


Today I was setting up a new project that was using Castle Windsor’s NLog integration facility. However, when I tried running my ASP.NET MVC project I got the following error:

Could not load file or assembly ‘NLog, Version=2.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

The solution was to add the following entry in the configuration file

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.1.0" newVersion="2.0.1.0" />
      </dependentAssembly>
    </assemblyBinding>
</runtime>

It is important to note the xml namespace. This workaround, I believe, is not specific to NLog or Castle. From my limited understanding, this is caused by the fact that I’ve got a newer version of NLog (2.0.1.0) while Castle Windsor is expecting version 2.0.0.0.

Advertisements
Posted in .NET, ALT.NET, Castle.Windsor, NLog, Troubleshooting

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: