Cannot find System.Web.Script.Service namespace error after upgrading to Visual studio 2010
Asked Answered
D

5

8

I've just upgraded a VS 2008 project to VS 2010, converting the project but keeping the target as .NET 3.5 (SP1 is installed). My project worked without issue under VS 2008 on another machine.

I've added references to System.Web.Extensions.dll but I'm still getting the following errors from code in the App_Code folder:

1) Cannot find System.Web.Script.Service namespace.

2) Type 'System.Web.Script.Services.ScriptService' is not defined.

3) Type 'System.Runtime.Serialization.Json.DataContractJsonSerializer' is not defined.

Anyone have any ideas what the problem might be as I'm pretty stumped? :(

Disappearance answered 16/6, 2010 at 12:27 Comment(2)
Interesting... when using the Object Browser in VS 2010 and drill down to C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Web.Extensions.dll > System.Web.Script.Services I can't find a ScriptService item. Also when I drill down to C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.Runtime.Serialization.dll > System.Runtime.Serialization I don't see a Json item either. Matches the problems reported in code. Am I missing some install?Disappearance
Also interesting is that if I target the 4.0 framework instead of 3.5 everything works fine. Unfortunately 4.0 isn't available on my web server yet :(Disappearance
D
5

Seems there's a bug from Microsoft where Target Framework for v3.5 in VS2010 is v3.0 of the GAC! Moving assemblies with issue to v3.0 folder seems to start resolving issues, but a bit messy. Think I'll wait for Microsoft to bring out a proper fix for VS 2010!

http://www.cnblogs.com/dudu/archive/2010/06/24/1764549.html

Google translate helps with this link!

More detail of assemblies copied to v3.0 folder from v3.5 folder as a work-around to this VS 2010 bug:

http://forums.asp.net/p/1569744/3942724.aspx

If anyone else is encountering this issue and wants to track / vote up the status of this bug with Microsoft: https://connect.microsoft.com/VisualStudio/feedback/details/570557/targeting-net-framework-3-5-actually-targets-3-0-gac

Update - Microsoft posted the following fix to the bug report I raised:

To build a web site targetting to 3.5, please add a compiler tag in your web.config file like I paste below, so language compilation will pick up the right version of vbc.exe. You can create a new 3.5 web site, and the default web.config has those tags you can reference.

<system.codedom>
  <compilers>
    <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <providerOption name="CompilerVersion" value="v3.5"/>
      <providerOption name="OptionInfer" value="true"/>
      <providerOption name="WarnAsError" value="false"/>
    </compiler>
  </compilers>
</system.codedom>
Disappearance answered 24/6, 2010 at 9:52 Comment(0)
T
17

In Visual Studio 2012, be sure to add reference for System.Web.Extensions as that is the one that holds System.Web.Script.Serialization.

Trichloromethane answered 20/6, 2013 at 17:41 Comment(0)
D
5

Seems there's a bug from Microsoft where Target Framework for v3.5 in VS2010 is v3.0 of the GAC! Moving assemblies with issue to v3.0 folder seems to start resolving issues, but a bit messy. Think I'll wait for Microsoft to bring out a proper fix for VS 2010!

http://www.cnblogs.com/dudu/archive/2010/06/24/1764549.html

Google translate helps with this link!

More detail of assemblies copied to v3.0 folder from v3.5 folder as a work-around to this VS 2010 bug:

http://forums.asp.net/p/1569744/3942724.aspx

If anyone else is encountering this issue and wants to track / vote up the status of this bug with Microsoft: https://connect.microsoft.com/VisualStudio/feedback/details/570557/targeting-net-framework-3-5-actually-targets-3-0-gac

Update - Microsoft posted the following fix to the bug report I raised:

To build a web site targetting to 3.5, please add a compiler tag in your web.config file like I paste below, so language compilation will pick up the right version of vbc.exe. You can create a new 3.5 web site, and the default web.config has those tags you can reference.

<system.codedom>
  <compilers>
    <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warningLevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
      <providerOption name="CompilerVersion" value="v3.5"/>
      <providerOption name="OptionInfer" value="true"/>
      <providerOption name="WarnAsError" value="false"/>
    </compiler>
  </compilers>
</system.codedom>
Disappearance answered 24/6, 2010 at 9:52 Comment(0)
T
1
  • Check your web.config assembly entries.

  • Check your .NET Framework target in your Visual Studio 2010 project, default is 4.0

  • Check IIS, make sure you are using the appropriate framework for your site. The new .NET 4.0 install can change your default Framework to 4.0.

Thrust answered 16/6, 2010 at 12:33 Comment(5)
Hi Rick, I already have these two entries: <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></assemblies>Disappearance
Hi Rick, cheers again but I'm already targeting 3.5 instead of 4.0. And I'm running the web site directly from VS 2010 so IIS shouldn't come in to play?Disappearance
Did your machine ever have Visual Studio 2010 Beta or RC? I had to manually remove some directories for the 2010 to work correctly.Thrust
Hi Rick - thanks for your ideas once again! No, the machine has fresh installs of all the newest toys as I've just upgraded the hard drive and decided to start fresh: Windows 7, VS 2010, Office 2010, Expression 4.Disappearance
Oh, and I also installed SQL Server 2008 R2 before VS 2010 in case that has any relevance (probably not).Disappearance
B
0

I've resolved a similar problem by changing my website's target framework from 3.5 to 4.0 and back to 3.5 again.

This resulted in a lot of additions to my web.config file that might be making it a lot easier for Visual Studio to support my project.

I never "upgraded my project to Visual Studio 2010", but this was an older aspx website and this may have been the first time it was opened with VS 2010.

Buy answered 4/10, 2012 at 15:38 Comment(0)
P
0

I've resolved a similar problem me too by changing my website's target framework from 3.5 to 4.0 and back to 3.5 again.

Porridge answered 26/6, 2013 at 10:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.