简体   繁体   中英

The type or namespace name 'Web' does not exist in the namespace 'System'

I am building a project in .NET Core where I need to use the Framework Assembly System.Web.Extension . I install the assembly via Reference -> Add Reference -> System.Web.Extension 4.0.0.0 . After it installed it appears under DNX 4.5.1 -> FrameworkAssemblies . Package restoration was successful as well.

Following entry is added in project.json file as expected.

"frameworkAssemblies": {"System.Web.Extensions": "4.0.0.0"}

But when I am trying to compile the project using dnu build , following error appears!

D:\\Projects\\ColemanApi\\src\\ColemanApi\\Controllers\\ValuesController.cs(7,14): DNXCore,Version=v5.0 error CS0234: The type or namespace name 'Web' does not exist in the namespace 'System' (are you missing an assembly reference?)

D:\\Projects\\ColemanApi\\src\\ColemanApi\\Controllers\\ValuesController.cs(51,27): DNXCore,Version=v5.0 error CS0246: The type or namespace name 'JavaScriptSerializer' could not be found (are you missing a using directive or an assembly reference?)

I was following this post but it does not have a solution for .net 5 or I don't know how to Copy Local in .net 5 as I did not see any Properties option in Assembly's fly-out menu.

Please see attached image: 在此输入图像描述

And here is a screenshot of the compilation error: 在此输入图像描述

Somebody please help. I am totally screwed up!

UPDATE

I ran dnu list and it shows the System.Web.Extensions is resolved. Please see the screenshot below:

在此输入图像描述

Thanks in advance.

If it does, is there any alternative solution to deserialize a JSON string without removing "dnxcore50"?

JSON.Net provides this functionality. If you want to use this on Core...

https://github.com/JamesNK/Newtonsoft.Json/issues/618#issuecomment-186441534

There won't be any progress until .NET Core RC2. When it is released I'll create a netstandard build and release a new version of Json.NET.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM