XDocument的编译错误

时间:2011-09-13 20:02:09

标签: asp.net linq-to-xml

我一直在为汽车经销商的网站工作。当网站准备好上线时,我们意识到他们使用的服务器是使用3.5框架设置的,不幸的是我在4.0中构建了网站而不是3.5。更改网站后我现在得到编译错误。

 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: CS0246: The type or namespace name 'XDocument' could not be found (are you missing a using directive or an assembly reference?)

 Line 99:      //query the database to search for New cars only     
 Line 100:     XDocument feed = XDocument.Load(Server.MapPath("VEHICLES.XML"));     

我认为错误是我在代码隐藏文件中调用我的程序集引用然后在页面本身中调用XDocument,这样我就可以运行搜索,然后将响应结果写到页面上。这适用于4.0但在3.5中它似乎无法找到程序集。我没有使用转发器,因为我需要检查某些事情,例如,如果汽车是否经过认证,我将其列在页面上,这样我就可以进行更改,这似乎不适用于转发器。

如果有人对如何解决此错误或如何更有效地解决此问题有任何想法,我会非常感激。

1 个答案:

答案 0 :(得分:3)

将此添加到班级的顶部...

Using System.Xml.Linq

如果仍然出现错误,请将System.Xml.Linq.dll引用添加到项目中。