Jaspal
Jaspal

Reputation: 93

system.web doesnt contain definition for script

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

Upvotes: 5

Views: 7113

Answers (4)

Arun Banik
Arun Banik

Reputation: 470

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

Upvotes: 1

Parham
Parham

Reputation: 1067

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

Upvotes: 1

Michael Petrotta
Michael Petrotta

Reputation: 60942

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;

Upvotes: 10

Andrey
Andrey

Reputation: 60075

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?

Upvotes: 5

Related Questions