问题
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" />
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'
I've been bashing my head against this all morning and I'm just not seeing it. Any ideas?
Thanks all.
回答1:
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.
来源:https://stackoverflow.com/questions/8300790/issue-using-assemblies-and-namespaces-in-msxsl