简体   繁体   中英

Issue using assemblies and namespaces in 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" />

I then have ac# 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.

我有同样的问题,显然模板返回的模板方法不能用于脚本,只有具有像ContainsKey()和Count这样的独特返回的方法是可用的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM