c#编译器说方法不存在

时间:2014-09-13 05:31:47

标签: asp.net linq-to-xml xelement csc

我在一个运行良好的非编译.aspx页面中开发了代码,但是当我将代码复制粘贴到代码隐藏页面时,c#编译器引发了错误:

  

错误CS1061:' System.Collections.Generic.IEnumerable'不包含' Descendants'的定义没有延伸方法'后代'接受类型为'System.Collections.Generic.IEnumerable'的第一个参数。可以找到(你错过了使用指令或程序集引用吗?)

有问题的一行:

 xdoc = System.Xml.Linq.XDocument.Parse(xmlReminders);
 var xdocReminders = from reminder in xdoc.Descendants("Reminders").Descendants("Reminder") select reminder;

编译器命令引用System.Xml.Linq.dll

csc.exe [...bunch of stuff...]  /reference:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.Xml.Linq.dll

和MSDN在XElement的文档中使用了这个方法:

  

Descendants(XName):按文档顺序返回此文档或元素的后代元素的过滤集合。只有具有匹配XName的元素才会包含在集合中。 (继承自XContainer。)

为什么在服务器上运行时编译和运行相同的代码,但不能手动编译?

作为参考,编译命令是:

  

C:\ WINDOWS \ Microsoft.NET \ Framework \ v4.0.30319 \ Csc.exe / nowarn:162,618,1701,1702 /reference:bin\aspNetEmail.dll /reference:bin\aspNetMime.dll / reference:bin \ aspNetPOP3.dll /reference:bin\Google.GData.AccessControl.dll /reference:bin\Google.GData.Calendar.dll /reference:bin\Google.GData.Client.dll /reference:bin\Google.GData.Extensions。 dll /reference:bin\DateTimePicker.dll /reference:bin\itextsharp.dll /reference:bin\AE.Net.Mail.dll /reference:bin\Newtonsoft.Json.dll /reference:bin\PushSharp.Apple.dll /参考:bin \ PushSharp.Core.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.Configuration.dll / reference:C:\ WINDOWS \ Microsoft.NET \ Framework \ v4.0.30319 \ System.Data.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.Drawing.dll /参考:C:\ WINDOWS \ Microsoft.NET \ Framework \ v4.0.30319 \ System.EnterpriseServices.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.Web.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.Web.Mobile.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.Web.Services.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.Xml.dll /reference:C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\System.Xml.Linq.dll / debug + / debug:full / optimize + /out:bin\MyDLL.dll / target:library [文件列表]

0 个答案:

没有答案