ASP.NET MVC / I use VkNet to post entries to a group in VK
At a certain time, the task scheduler makes a GET request with a key to a specific Action ( https://mydomain.com/Service/Vk?key=SECRET_KEY )
After that, the Action logic is executed and at the end the method responsible for working with VkNet is called:
VkontakteService.WallPost(APPID, "LOGIN", "PWD", OWNERID, message); Method:
public static void WallPost(ulong appId, string login, string password, long ownerId, string message) { try { VkApi api = new VkApi(); api.Authorize(new ApiAuthParams { ApplicationId = appId, Login = login, Password = password, Settings = Settings.All }); api.Wall.Post(new WallPostParams { OwnerId = ownerId, FromGroup = true, Message = message, Signed = false, }); } catch (Exception ex) { Log.Error($"Ошибка при добавлении записи в группу ВК: {ex}"); } } As a result, I get a strange Exception :
[2016-11-21 23:13:11.3353][Error]: Ошибка при добавлении записи в группу ВК: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, 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) System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=9.0.0.0, 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=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' at VkNet.VkApi.Call(String methodName, VkParameters parameters, Boolean skipAuthorization) at VkNet.Categories.WallCategory.Post(WallPostParams params) at MyProject.Services.VkontakteService.WallPost(UInt64 appId, String login, String password, Int64 ownerId, String message) in D:\MyProject\trunk\Sources\MyProject.Services\VkontakteService.cs:line 27 === Pre-bind state information === LOG: DisplayName = Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed (Fully-specified) LOG: Appbase = file:///D:/MyProject/trunk/Sources/MyProject.Host/ LOG: Initial PrivatePath = D:\MyProject\trunk\Sources\MyProject.Host\bin Calling assembly : VkNet, Version=1.21.0.0, Culture=neutral, PublicKeyToken=null. === LOG: This bind starts in default load context. LOG: Using application configuration file: D:\MyProject\trunk\Sources\MyProject.Host\web.config LOG: Using host configuration file: C:\Users\Home\Documents\IISExpress\config\aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed LOG: Attempting download of new URL file:///C:/Users/Home/AppData/Local/Temp/Temporary ASP.NET Files/root/ee02bc37/45707ec2/Newtonsoft.Json.DLL. LOG: Attempting download of new URL file:///C:/Users/Home/AppData/Local/Temp/Temporary ASP.NET Files/root/ee02bc37/45707ec2/Newtonsoft.Json/Newtonsoft.Json.DLL. LOG: Attempting download of new URL file:///D:/MyProject/trunk/Sources/MyProject.Host/bin/Newtonsoft.Json.DLL. WRN: Comparing the assembly name resulted in the mismatch: Major Version ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated. The VkontakteService class itself with the WallPost method lies in a neighboring project (Class Library) with a connected VkNet
App.config
<?xml version="1.0" encoding="utf-8"?> <configuration> <configSections> <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> </configSections> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="HtmlAgilityPack" publicKeyToken="bd319b19eaf3b43a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.4.9.5" newVersion="1.4.9.5" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> Tell me what could be the problem, can anyone encountered such errors, I just see such a strange log for the first time?