.net - 使用 ColdFusion 中的列表调用 .NET 方法时未找到方法

标签 .net coldfusion coldfusion-10

对于某些背景,这与 Passing IEnumerable Variables into .NET from ColdFusion 相关。 。我已更改代码以使用列表,并取得了进展,但在使用 .NET 和 ColdFusion 的简单数据类型以外的任何内容时,仍然遇到障碍。这就是当前的问题。

首先,我有一个包含以下 VideoWallEvent.cs 文件的 .dll:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CoStar.Utilities.VideoWall
{
    public class VideoWallEventActivityCollection
    {
        public string CountryCode { get; set; }
        public DateTime ActivityDate { get; set; }
        public List<VideoWallEvent> Events { get; set; }

    }

    public class VideoWallEvent
    {

        public string ID { get; set; }
        public decimal Latitude { get; set; }
        public decimal Longitude { get; set; }

        public VideoWallEvent(string EventID, decimal EventLatitude, decimal EventLongitude)
        {
            ID = EventID;
            Latitude = EventLatitude;
            Longitude = EventLongitude;
        }
    }
}

我还按照上一个问题的说明使用 JNBProxyGUI.exe 生成了一个代理对象对象。鉴于上面的 dll 和我生成的代理 jar,我运行以下 ColdFusion 代码:

<cfset UtilitiesProxy = ExpandPath("UtilitiesProxy.jar") />
<cfset CoStarUtilities = ExpandPath("CoStar.Utilities.dll") />
<cfset Paths = ArrayToList([CoStarUtilities, UtilitiesProxy])>

<cfset theEvent = CreateObject(".net", "CoStar.Utilities.VideoWall.VideoWallEvent", Paths) />
<cfset eventList = CreateObject(".net","System.Collections.Generic.List`1", Paths).init(theEvent.getDotNetClass()) />

<cfset eventList.Add(theEvent.Init("1234", javacast("bigdecimal","30.2669444"), javacast("bigdecimal","-97.7427778"))) />
<cfset eventList.Add(theEvent.Init("1235", javacast("bigdecimal","30.2669444"), javacast("bigdecimal","-97.7427778"))) />

<cfset eventCollection = CreateObject(".net", "CoStar.Utilities.VideoWall.VideoWallEventActivityCollection", CoStarUtilities) />
<cfdump var="#eventList.ToArray()#" label="Items in eventList" />
<hr />
<cfdump var="#eventCollection#" label="eventCollection" />
<cfdump var="#eventList#" label="eventList" />

<cfset eventCollection.Set_Events(eventList) />

这给了我以下输出:

enter image description here

正如您从屏幕截图中看到的,我可以成功地将项目添加到列表中,我可以获得需要 List 对象的 ActivityCollection 对象,但是调用 Set_Events 方法并传递 List 会抛出以下错误:

The Set_Events method was not found.

Either there are no methods with the specified method name and argument types 
or the Set_Events method is overloaded with argument types that ColdFusion cannot
decipher reliably. ColdFusion found 0 methods that match the provided arguments. 
If this is a Java object and you verified that the method exists, use the javacast 
function to reduce ambiguity.

The error occurred in C:/inetpub/scribble/VideoWall/index.cfm: line 17
15 :    <cfdump var="#eventList#" label="eventList" />
16 : 
17 :    <cfset eventCollection.Set_Events(eventList) />

所以我现在需要帮助弄清楚如何正确地将这个列表推送到 Set_Events() 方法中。

最佳答案

(来自评论)

不管你信不信,这只是一个程序集路径问题。您必须使用汇编列表中的两个文件,而不仅仅是 CoStarUtilities,即:

 <cfset eventCollection = CreateObject(".net"
                 , "CoStar.Utilities.VideoWall.VideoWallEventActivityCollection"
                 , Paths ) />

关于.net - 使用 ColdFusion 中的列表调用 .NET 方法时未找到方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16818747/

相关文章:

c# - GridView 行编辑

c# - Environment.GetEnvironmentVariable 找不到变量值

.net - .net 中流行哪些 BDD 框架?

html - 十进制在sql中被截断

.net - 包含字段的 TextFieldParser 不是“”

database-design - 我如何创建一个架构,允许许多客户使用一个网站,每个网站都有不同的功能?

iis - 将 IIS 网站绑定(bind)到第二个 ColdFusion 实例

jquery - 使用 AJAX 将表单数据发送到 Fw/1(Coldfusion) Controller 功能

coldfusion - 尝试通过 CF10 管理员更新时出现错误 "Failed Signature verification"

Coldfusion 在网络驱动器上创建目录