Issue using assemblies and namespaces in msxsl

萝らか妹 提交于 2020-01-03 12:33:07

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!