【发布时间】:2012-01-08 04:53:57
【问题描述】:
我有一个 XSL 转换,它使用 msxsl 在 C# 中添加扩展方法。我有以下 msxsl 设置:
<msxsl:script language="C#" implements-prefix="cs">
<msxsl:assembly name="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<msxsl:assembly name="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<msxsl:using namespace="System.Collections.Generic" />
<msxsl:using namespace="System.Linq" />
<msxsl:using namespace="System.Xml.Linq" />
然后我有一个 c# 函数作为扩展方法:
public int returnUniqueCount(string theCodeCollection) {
// calculate and return the total number of distinct codes
if (theCodeCollection.Length > 0) {
string[] myObject = theCodeCollection.Split('|');
string[] uniqueCollection = myObject.Distinct().ToArray();
return uniqueCollection.Length;
} else {
return 0;
}
}
本质上,它只需要一个标记化的字符串,将其拆分,然后计算不包括重复项的结果集。
转换在服务器上运行良好,但是当我尝试对其进行分析时,我收到以下错误:
'System.Array' does not contain a definition for 'Distinct'
我整个早上都在为此苦苦挣扎,但我只是没有看到它。有什么想法吗?
谢谢大家。
【问题讨论】:
-
你是什么意思:“当我尝试分析它时......”?你到底在做什么?
-
您在分析时是否使用不同版本的 .NET 运行/编译?