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=4.0.0.0, 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;

                }
                else
                {
                    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).

问题评论:

原文地址:

https://stackoverflow.com/questions/47743060/system-typeloadexception-cant-load-system-web-util-from-assembly-system-web

Add a Comment