简体   繁体   中英

Newtonsoft.Json - A first chance exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll

This is really confusing me. I have a VS solution - an Azure Cloud Service with one worker role.

I've isolated the problem to a single line of code in the worker role, which is otherwise completely empty and does nothing.

var json = JsonConvert.SerializeObject(model);

If comment this line out, a can hit a breakpoint at the start of the worker role. If I include it, the breakpoint never gets hit, and I get an error in the output:

A first chance exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll

I've tried uninstalling all packages in the solution, deleting everything in the packages folder, and reinstalling. No luck!

Try checking the hint path on the reference to newtonsoft.json. I'm assuming its a nuget package reference so should be pointing at a path in your packages folder.

I have seen this happen when VS changes the hint path to another projects bin folder and the build server fails to copy the referenced dlls properly.

May not be your issue but worth a check.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM