首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >命名空间中不存在脚本。找不到ScriptService

命名空间中不存在脚本。找不到ScriptService
EN

Stack Overflow用户
提问于 2012-09-28 03:38:37
回答 2查看 11.3K关注 0票数 1

大约一天以来,我一直在努力摆脱三个编译器错误。

错误如下:

代码语言:javascript
复制
> Error 1   The type or namespace name 'Script' does not exist in the
> namespace 'System.Web' (are you missing an assembly
> reference?)   D:\WebData\Intranet\depts\MSO\msow_reports\App_Code\SearchPract.cs  7   18  http://localhost/depts/MSO/msow_reports/
> Error 2   The type or namespace name 'ScriptService' could not be found
> (are you missing a using directive or an assembly
> reference?)   D:\WebData\Intranet\depts\MSO\msow_reports\App_Code\SearchPract.cs  14  2   http://localhost/depts/MSO/msow_reports/
> Error 3   The type or namespace name 'Script' does not exist in the
> namespace 'System.Web' (are you missing an assembly
> reference?)   D:\WebData\Intranet\depts\MSO\msow_reports\App_Code\SearchPract.cs  26  17  http://localhost/depts/MSO/msow_reports/

该项目是我正在尝试导入到Visual Studio2010中的.net 3.5项目。我已经尝试过更新到.net 4并保留为.net 3.5。我的理解是脚本和ScriptService应该在System.Web.Extensions dll中。添加对此程序集的引用似乎不起作用。

请注意以下摘录自我的Web.config文件:

代码语言:javascript
复制
<compilation debug="true">
  <assemblies>
    <add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="eWorld.UI, Version=2.0.6.2393, Culture=neutral, PublicKeyToken=24D65337282035F2"/>
    <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
    <add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
    <add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
    <add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
    <add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
  </assemblies>
</compilation>

不满意的代码如下:

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Web.Services;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web.Script.Services;

/// <summary>
/// Summary description for SearchPract
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class SearchPract : System.Web.Services.WebService {

    public SearchPract () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [System.Web.Services.WebMethod]
    [System.Web.Script.Services.ScriptMethod]
    public string[] GetPracts(string prefixText, int count) 

我已经尝试将System.Web.Extensions.dll和System.Web.Extensions.Design.dll以及web.config文件添加到Bin文件夹中。当浏览“我的解决方案”时,System.Web.Extensions程序集仍然不会显示在对象浏览器中。我想这就是问题的症结所在。在这一点上,我不知道从现在开始尝试什么。

我想知道我是不是忽略了什么明显的东西。

请让我知道我应该提供什么其他信息。

EN

回答 2

Stack Overflow用户

发布于 2014-04-27 14:13:39

使用ASP2.0版,你可以添加微软开发的System.Web.Extensions.DLL 1.0.61231.0版,它适用于我的项目,使用.NET .net 2.0在mono上发布。

票数 1
EN

Stack Overflow用户

发布于 2013-01-02 15:18:43

从文档中,

ScriptService来自.NET版本3.5。

如果你的项目有一个比上面提到的版本低的版本,那么很明显它永远不会工作。

要使其正常工作,您需要将项目的版本更改为更高版本。请按照以下步骤操作:

代码语言:javascript
复制
myProject Properties --> Application --> Target Framework --> Set it to >3.5
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12628854

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档