问题描述
在我的VSTO Excel项目中,我正在调用一种方法 在我引用的另一个项目的类中。此方法返回IEnumerable< MyClass>。当我尝试在调用此方法的结果上调用ToArray()时,我得到的是''object'
不包含'ToArray'的定义。我有"使用System.Linq"在我班上如果我从另一个非vsto项目调用此方法,它就像我期望的那样工作。似乎我设置为此方法
调用结果的变量发现自己绑定为动态变量。为什么会发生这种情况超出我的想法。
In my VSTO Excel project I'm calling a method in a class from another project that I have referenced. This method returns an IEnumerable<MyClass>. When I try to call ToArray() on the results from calling this method all I get is "'object' does not contain a definition for 'ToArray'". I have "using System.Linq" in my class. If I call this method from another, non vsto project, it all works just as I would expect. It seems as if the variable that I set to the result of this method call finds itself bound as a dynamic variable. Why this happens though is beyond me.
任何想法?
推荐答案
private IEnumerable<MyClass> GetMatches(int value, DateTime from, DateTime to)
{
yield break;
}
如果我从同一个类调用此方法并尝试调用ToArray()结果我得到的是:
If I call this method from the same class and try to call ToArray() on the result all I get is this:
'Sportnik.Excel.Stff。< GetMatches> d__11'
不包含定义
for 'ToArray'
'Sportnik.Excel.Stff.<GetMatches>d__11'does not contain a definitionfor'ToArray'
这篇关于扩展方法在vsto项目中失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!