未找到方法使用ColdFusion中的List调用.NET方法 [英] Method Not Found Calling .NET Method with List from ColdFusion

查看:174
本文介绍了未找到方法使用ColdFusion中的List调用.NET方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于某些背景,这与将IEnumerable变量传递到.NET中有关ColdFusion 。我已经改变代码使用列表,而且已经取得进展,但是当使用.NET和ColdFusion的简单数据类型之外的其他任何东西时,继续打破障碍。所以这里是当前的问题。

For some background, this is related to Passing IEnumerable Variables into .NET from ColdFusion. I've changed the code to use a list instead, and have made progress, but continue to hit roadblocks when using anything other than simple data types with .NET and ColdFusion. So here's the current issue.

首先,我有一个.dll与下面的VideoWallEvent.cs文件:

First, I have a .dll with the following VideoWallEvent.cs file:

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代码:

I've also generated a proxy object object using JNBProxyGUI.exe following instructions from the prior question. Give that the above dll, and the proxy jar I've generated, I run the following ColdFusion code:

<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) />

这给我以下输出:

从截图中,我可以成功添加项到列表,我可以得到期望一个List对象的ActivityCollection对象,但调用 Set_Events 方法,并传递List引发以下错误:

As you can see from the screenshot, I can successfully add items to the list, I can get the ActivityCollection object that expects a List object, but calling the Set_Events method and passing the List throws the following error:

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 / p>

So I now need help figuring out how to properly push this List into the Set_Events() method.

推荐答案

(来自评论)

(From the comments)

相信它或不是它只是一个装配路径问题。您必须在程序集列表中使用这两个文件,而不仅仅是 CoStarUtilities ,即:

Believe it or not it is just an assembly path problem. You have to use both files in the assembly list, not just CoStarUtilities, ie:

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

这篇关于未找到方法使用ColdFusion中的List调用.NET方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆