Programming Language · 2017-12-12 0

System.TypeLoadException–can’t load System.Web.Util from assembly System.Web?


I am attempting to create a program that loads IMDB data from the OMDb API upon getting a request containing the name of the movie to get data from. When I run the program, testing it by trying to get data from the movie The Shawshank Redemption, I get this error:

Could not load type ‘System.Web.Util.Utf16StringValidator’ from assembly ‘System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’.

using (WebClient wc = new WebClient())
                var json = wc.DownloadString(url);
                JavaScriptSerializer oJS = new JavaScriptSerializer();
                ImdbEntity obj = new ImdbEntity();
                obj = oJS.Deserialize<ImdbEntity>(json); // This is the line that causes the problem in debug.
                if (obj.Response == "True")
                    string txtActor = obj.Actors;
                    string txtDirector = obj.Director;
                    string txtYear = obj.Year;

                    Console.WriteLine("Movie not found.");


(Yes, I am getting the code from another StackOverflow question, but I’m an absolute beginner at this.)

I have System.Web.Extensions.dll referenced in my project (and have the using statement using System.Web.Script.Serialization).



Would love your thoughts, please comment.x