theboyknowsclass
theboyknowsclass

Reputation: 31

IO Exception Could not load file or assembly 'System.Runtime' Error when using JsonConvert.SerializeObject

I've created a Portable Class Library, using the nuget packages for JSON.NET and the Async package

when I try and serialize a class within the portable library I get this error, in my unit test project

Could not load file or assembly 'System.Runtime, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

I only seem to get it when there is an public async method on the class. Also if I recreate the class within in the test project then it works fine. The error only occurs when calling into the portable library (to serialize a class with an async method)

Upvotes: 3

Views: 3731

Answers (1)

Daniel Plaisted
Daniel Plaisted

Reputation: 16744

You should be able to remove any binding redirects from your app.config for assemblies installed as part of the Microsoft.Bcl or Microsoft.Bcl.Async NuGet packages. The Microsoft.Bcl.Build package will add the correct binding redirects at compile time.

Upvotes: 3

Related Questions