在msxsl中使用程序集和名称空间的问题 [英] Issue using assemblies and namespaces in msxsl
问题描述
我有一个XSL转换,该转换使用msxsl在C#中添加扩展方法.我为msxsl设置了以下设置:
I have an XSL transform that is using msxsl to add extension methods in C#. I have the following setup for 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#函数作为扩展方法:
I then have a c# function as an extension method:
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;
}
}
从本质上讲,它只需要一个带标记的字符串,将其拆分,然后对结果集进行计数(不包括重复项).
Essentially that just takes a tokenized string, splits it, and counts the result set excluding duplicates.
该转换在服务器上运行良好,但是当我尝试对其进行概要分析时,出现以下错误:
The transform runs fine on the server, but when I try to profile it, I get the following error:
'System.Array' does not contain a definition for 'Distinct'
整个早晨,我一直在ash头,但我只是没有看到它.有什么想法吗?
I've been bashing my head against this all morning and I'm just not seeing it. Any ideas?
谢谢.
推荐答案
我遇到了同样的问题,显然具有模板返回值的模板方法无法用于脚本编写,只有具有明显返回值的方法(如ContainsKey()和Count)才可用.可用.
I have the same problem, apparently template methods that has a template return are not available for scripting, only methods that has a distinct return like ContainsKey() and Count are availble.
这篇关于在msxsl中使用程序集和名称空间的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!