bugsnag/bugsnag-dotnet

FileNotFoundException when using newer version of Newtonsoft.Json

sarendshorst opened this issue · 3 comments

In NuGet manager BugSnag claims to support Newtonsoft.Json (>= 6.0.1), but when I use the latest version (10.0.3) I get the following exception:

Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

It works fine when using version 6.0.1. Is there any way to use the latest version of Newtonsoft.Json with BugSnag?

I have the same issue and don't want to downgrade the version of newtonsoft.

Is there another workaround or fix for this issue?

I have discovered what the problem is.

Issue
If you take a look at the following file, lines 67-74

https://github.com/bugsnag/bugsnag-dotnet/blob/22eaea4db0a6d34e8ef476e66600cf839fa7f401/src/Bugsnag/Bugsnag.csproj

There are references to both System.Web.Http and System.Web.Mvc.

The problem is that it requires you to pull in both references to your project which isn't really ideal, especially if you don't need any Web Api specific functionality in your web project.

Fix
An ideal fix is for Bugsnag to create two separate packages, one for .net Mvc and one for Web Api. If you want to use both in your projects then import both, but it's also flexible enough to use one or the other.

Workaround
In the meantime, you can import System.Web.Http to your project and then add the following reference to the web.config file:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
            <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
        </dependentAssembly>
    </assemblyBinding>
</runtime>

@NFear @michaeldalyuk version 2 of the notifier which is currently in alpha will remove the dependency on Newtonsoft.Json so this should no longer be an issue. Please let us know if you continue to have issues once version 2 is released