I have pretty big solution with about 80 projects, running on the Azure cloud service server as Web role using WebAPI (v1). I have created new enhancement regarding content negotiation by implementing custom
JsonReader/Writer. When I have tried use it by implementing custom
MediaTypeFormatter based on the
BaseJsonMediaTypeFormatter it fails - to be precise, it fails when published to the Azure. Locally emulated it works perfectly. Once published it fails as:
... Role entrypoint could not be created: System.TypeLoadException: Unable to load the role entry point due to the following exceptions: -- System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=18.104.22.168, 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) File name: 'Newtonsoft.Json, Version=22.214.171.124, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' === Pre-bind state information === LOG: DisplayName = Newtonsoft.Json, Version=126.96.36.199, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed (Fully-specified) LOG: Appbase = file:///E:/approot/bin LOG: Initial PrivatePath = E:\approot\bin Calling assembly : System.Net.Http.Formatting, Version=188.8.131.52, Culture=neutral, PublicKeyToken=31bf3856ad364e35. ...
(Log captured from EventViewer->Application and Services log->Windows Azure).
Until I tried to use my custom
MediaTypeFormatter everything worked correctly. I have searched internet and SO for some solution, and although the problem is not as rare as I thought none of the solution helped me. What have I tried:
Newtonsoft.Jsonnugets in all referencing projects
csprojmanually for referencing old
web.configfile contains (and have always contained) correct
None of the solution worked and I still get this strange message. My questions are:
System.Net.Http.Formattinglibrary requires some specific version of Newtonsoft.Json when I explicitly say it should redirect to the 12th version? Is it because it happens during Webrole start (maybe because it doesn't respect web.config yet?)
Any hint to find the issue will be appreciated.
User contributions licensed under CC BY-SA 3.0