5
votes

The type or namespace name 'Script' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

it gives error in the following line "System.Web.Script.Services.ScriptService"

i have included name space of system.web

4

4 Answers

10
votes

Two problems:

  1. The class System.Web.Script.Services.ScriptServiceAttribute exists in the System.Web.Extensions assembly, not System.Web. Make sure you're referencing the System.Web.Extensions assembly in your project.
  2. When referencing an attribute explicitly, you'll need to provide its full name of "ScriptServiceAttribute", and not just "ScriptService".

Once I referenced System.Web.Extensions, the following compiled for me:

System.Web.Script.Services.ScriptServiceAttribute ss;
5
votes

Google is your best friend. MSDN second.

ScriptServiceAttribute Class

Namespace: System.Web.Script.Services

Assembly: System.Web.Extensions (in System.Web.Extensions.dll)

did you add reference to this dll?

1
votes

look into C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\ and see if you find System.Web.Extensions.dll or the path if you don't have the dll you can Download and install the ASP.NET AJAX 1.0 from http://www.microsoft.com/en-us/download/details.aspx?id=883

1
votes

Add targetFramework to you web.config file.

<compilation debug="false" strict="false" explicit="true" **targetFramework="4.0"** />

It usually happens when you migrate codes particularly web methods from an older version, say .net 3.5 to a newer version.

Arun