Not able to run Service Fabric with right NewtonSoft.Json version in Local cluster


I am developing a service fabric application and testing it locally using visual studio 2019. The Application is named "DASSFHLSFApp1" and the service is DASSFHLSFAppServiceStateless1.

When I run this in local cluster, I get exception which trying to access Microsoft.WindowsAzure.Storage types. Exception I get is

Could not load file or assembly 'Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

When I used fuslogvw.exe I found that it Service Fabric is trying to load the NewtonSot.Json dll from

Services Package Code as shown below from fuslogvw.exe

Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Appbase = file:///C:/SfDevCluster/Data/_App/_Node_0/DassFHLSFApp1Type_App87/DassFHLSFAppServiceStateless1Pkg.Code.1.0.0/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = DassFHLSFAppServiceStateless1.exe
Calling assembly : Microsoft.WindowsAzure.Storage, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\SfDevCluster\Data\_App\_Node_0\DassFHLSFApp1Type_App87\DassFHLSFAppServiceStateless1Pkg.Code.1.0.0\DassFHLSFAppServiceStateless1.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: redirected to
LOG: Post-policy reference: Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/SfDevCluster/Data/_App/_Node_0/DassFHLSFApp1Type_App87/DassFHLSFAppServiceStateless1Pkg.Code.1.0.0/Newtonsoft.Json.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\SfDevCluster\Data\_App\_Node_0\DassFHLSFApp1Type_App87\DassFHLSFAppServiceStateless1Pkg.Code.1.0.0\Newtonsoft.Json.dll
LOG: Entering run-from-source setup phase.
LOG: Assembly Name is: Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Run-from-source setup phase failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

As you can see its picking version from the above location. I also found that "Newtonsoft.Json version 6.0.0" automatically gets references to by service project references. Even If I remove it, on restart of visual studio it gets automatically added

enter image description here

I'm not sure why the version 6.0.0 is getting added to project and moving to C:/SfDevCluster/Data/_App/_Node_0/DassFHLSFApp1Type_App87/DassFHLSFAppServiceStateless1Pkg.Code.1.0.0/Newtonsoft.Json.DLL.

I have added binding re directs in the app.config file

    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="" newVersion="" />

But When I try to install nuget NewtonSoft.Json 10.0.3 that also fails with error

Failed to add reference to 'Newtonsoft.Json'. Cannot modify an evaluated object originating in an imported file "...........props" file.

how do I fix these issues to be able to locally run my SF code for testing and not get the Exception "Could not load file or assembly 'NewtonSoft.Json Version 10.0.30"

asked on Stack Overflow Mar 30, 2021 by Sourav Sain • edited Mar 30, 2021 by James Z

1 Answer


The nutget package 'WindowsAzure.Storage' is deprecated and was split up into smaller packages. See the nuget docu. Maybe updating to the newer packages for example 'Microsoft.Azure.Storage.Blob' could solve the problem.

Newtonsoft 6.0.0 doesn't exist (see list of versions). Maybe it is worth a try to install 6.0.8. So, figuring out the problem step by step ;-)

answered on Stack Overflow Mar 31, 2021 by Boologne • edited Mar 31, 2021 by Boologne

User contributions licensed under CC BY-SA 3.0