当视图委托调用另一个方法时,为什么在 Acumatica 中会出现 C# 转换错误?

Why do I get a C# casting error in Acumatica when a View delegate calls another method?

我有一个带有自定义图形的自定义屏幕,我的图形有一个视图委托,它调用同一图形中的另一个方法。看起来并没有那么疯狂,但是 Acumatica 抛出了一个异常:

Unable to cast object of type '<GetVersions>d__25' to type 'System.Collections.IDictionary'.

我的委托方法就是这样:

protected virtual IEnumerable reportVersions()
{
    yield return GetVersions();
}

public virtual IEnumerable GetVersions()
{
    yield return null;
}

然而,当我拔掉电话时:

protected virtual IEnumerable reportVersions()
{
    yield return null;    
}

没有错误。调用堆栈很长,但似乎是在引用视图的网格在页面上呈现并将其作为数据源绑定到此时发生的。这是调用堆栈的顶部:

[InvalidCastException: Unable to cast object of type '<GetVersions>d__25' to type 'System.Collections.IDictionary'.]
PX.Data.PXCache`1.GetValueInt(Object data, String fieldName, Boolean forceState, Boolean externalCall) +807
PX.Data.PXCache`1.GetValueExt(Object data, String fieldName) +123
PX.Data.PXGraph.GetValueExt(String viewName, Object data, String fieldName) +126
PX.Web.UI.PXBaseDataSource.GetValueExt(String viewName, Object data, String fieldName) +151
PX.Web.UI.PXDataSourceView.GetValue(Object data, String fieldName) +42
PX.Web.UI.PXFormDataProvider.GetFieldValue(String field, DataSourceView view)
...

它似乎正在尝试检索字段值。有什么想法吗?

通过这个

改变reportVersions()方法
    protected virtual IEnumerable reportVersions()
    {
        return GetVersions();
    }  

    protected virtual IEnumerable reportVersions()
    {
        foreach (var item in GetVersions())
        {
            yield return item;
        }
    }