Windows Form Error: Could not load file or assembly Newtonsoft.Json or one of its dependencies. The system cannot find the file specified

Last Reply 7 months ago By Waghmare

Posted 7 months ago

Hi team,

Please help me to call my WEB api from win form application.

I am getting error as below. Please suggest me change in my code or new solution i have tried below link solution but not works. - 

Call (Consume) Web API in Windows Forms Application using C#

Could not load file or assembly 'Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

at Line : 

 HttpResponseMessage response_1 = client.PostAsJsonAsync("/api/AddEmployee/Post", addEmployees_1).Result;

 C# win form code

            JavaScriptSerializer javaScriptSerializer = new JavaScriptSerializer();

            List<AddEmployee> AddEmployee_List = (List<AddEmployee>)javaScriptSerializer.Deserialize(jsonstring, typeof(List<AddEmployee>));

            foreach (AddEmployee addEmployees_1 in AddEmployee_List)
                using (var client = new HttpClient())
                    client.BaseAddress = new Uri("http://localhost:63481/");

                    HttpResponseMessage response_1 = client.PostAsJsonAsync("/api/AddEmployee/Post", addEmployees_1).Result;
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    if (response_1.IsSuccessStatusCode)
                        label1.Text = "Success";


This question does not have replies that have been liked.