如何解决cs0433 system.web.extensions的错误

如果机器上同时安装了VS2008和VS2005,在用2005编译AJAX项目时,可能会出现这样的错误:

Compiler Error Message: CS0433: The type 'System.Web.UI.ScriptManager' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\1.0.61025.0__31bf3856ad364e35\System.Web.Extensions.dll'

解决方案:
1.打开web.config,找到以下相关结点:
  <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"></add>
    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Data.Linq, 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.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
2.将这些结果注释掉或删除,再重新编译就可以了.

这是因为VS2005编译的AJAX是1.0的,而VS2008能同时编译AJAX1.0和其他版本的.所以会出现冲突.

出错页面提示信息如下:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0433: The type 'System.Web.UI.ScriptManager' exists in both 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.5.0.0__31bf3856ad364e35\System.Web.Extensions.dll' and 'c:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\1.0.61025.0__31bf3856ad364e35\System.Web.Extensions.dll'

Source Error:

Line 8:  <body>
            Line 9:      <form id="form1" runat="server">
            Line 10:         <asp:ScriptManager ID="ScriptManager1" runat="server" />
            Line 11:         <div>
            Line 12:             <asp:UpdatePanel ID="UpdatePanel1" runat="server">

Source File: d:\AJAXEnabledWebSite1\Default.aspx    Line: 10
posted on 2008-01-23 10:06  名可真难起  阅读(8169)  评论(3编辑  收藏  举报