0

I am creating a project in .net core 3.1 i am getting error in following line

 using System.Web.Script.Serialization;
 jsonPayload = new JavaScriptSerializer().Serialize(interopMessageModel);
Severity    Code    Description Project File    Line    Suppression State
Error   CS0234  The type or namespace name 'Script' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)   
Severity    Code    Description Project File    Line    Suppression State
Error   CS0246  The type or namespace name 'JavaScriptSerializer' could not be found (are you missing a using directive or an assembly reference?)  

I found one sol here but did not understand how to resolve it for VS 2019

  • Mind that newtonsoft is not supported in net core 3.1, but it is recommended to work with System.Net.Json. If you still want to work with it: https://stackoverflow.com/questions/61204435/migration-to-net-core-3-1-netwonsoft-missing – Dani Toker May 25 '20 at 04:55
  • 1
    System.Web.Extensions is part of full .net framework . If you want to serialize and deserialize object,You can use Newtonsoft.Json.Refer to this [link](https://stackoverflow.com/questions/45687851/how-to-add-system-web-extensions-assembly-to-net-core-project-in-vscode) – mj1313 May 26 '20 at 09:41

1 Answers1

0

Add System.Web.Extension. It contains namespace System.Web.Script.Serialization.

v.t.
  • 41
  • 2