1

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: enter image description here

And here is a screenshot of the compilation error: enter image description here

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:

enter image description here

Thanks in advance.

Community
  • 1
  • 1
Subrata Sarkar
  • 2,975
  • 6
  • 45
  • 85
  • System.web.Extensions doesn't exist in the Core Clr so the problem isn't the assembly reference it is the additional build for dnxcore50. If you remove "dnxcore50" from your project.json the error should go away. you wont be able to build coreclr though because of that reference. – David Driscoll Feb 22 '16 at 12:46
  • Removing "dnxcore50" compiles without error. But does this mess up the project anyway if I take out "dnxcore50"? If it does, is there any alternative solution to deserialize a JSON string without removing "dnxcore50"? – Subrata Sarkar Feb 22 '16 at 12:57
  • The `frameworks` object is basically telling `dnx` to cross-compile your application for both `dnx451` (desktop clr) and `dnxcore50` (the new CoreCLR). `System.Web.Extensions` isn't available on the new CoreCLR, so for your case you just cannot cross compile your project for both frameworks, you can only compile for the desktop clr – David Driscoll Feb 22 '16 at 14:48

1 Answers1

0

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.

Emyr
  • 2,351
  • 18
  • 38