开发者

Error Using JSON.NET

I am trying to use JSON.NET and after including the .dll and trying to use one of the methods I get this error:

Could not load file or assembly 'Newtonsoft.Json.Net35, Version=4.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6开发者_Python百科b2a6aeed' or one of its dependencies. The system cannot find the file specified.

Any know why I might be this error?


Two things to check:

(1) You may have to "Unblock" the DLL. By default, when you download a .zip file from the Internet, that file, and all .dll or .exe files extracted from that .zip file, are given a file system attribute that prevents them from loading and executing. Right-click on the DLL in Windows Explorer, choose "Properties", and in the resulting dialog box click on the "Unblock" button. Or better yet, do that for the .zip file, and then re-extract all the files.

(2) The Newtonsoft JSON.NET library comes in five flavors: one each for .NET 2.0, 3.5, 4.0, Silverlight, and Windows Phone. You need to use the right one for your particular environment. I presume that this is a .NET 3.5 project?


In my case, I resolved this problem once I realized that a library that I was using was itself using the Json.NET but with the earlier version (3.5). Linking the second library to the new Json.NET version solved the issue.

Hope this helps.


You need to download release 1 instead of release 2 of the Newtonsoft.Json.


try to add assembly binding redirect to app config like:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.5.0.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

Related posts:

System.IO.FileNotFoundException

At least one module has an unresolved import

Debugging tests that require an external dll

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜