【发布时间】:2013-05-29 16:01:29
【问题描述】:
对于某些背景,这与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) />
这给了我以下输出:
从截图中可以看出,我可以成功地将项目添加到列表中,我可以获取需要 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) />
所以我现在需要帮助弄清楚如何正确地将这个 List 推送到 Set_Events() 方法中。
【问题讨论】:
-
我很想知道如果你调用
你会得到什么 -
我想知道 DotNetProxy 是否错误地设置了 Set_Events() mutator。我想知道如果您在构造过程中使用空 List
初始化 Events 属性是否会有所不同。 -
如果我是那种说脏话的人,我会发誓……一个法律。我在路径参数中只使用了 Utilities.dll。一旦我包含了 Utilities.dll 和我从 JNBProxyGUI.exe 创建的代理,一切似乎都在正确填充。
-
信不信由你,这只是一个组装路径问题。您必须在程序集列表中使用这两个 jar,而不仅仅是
CoStarUtilities。 (编辑:-没关系我看到你抓住了)。 -
Leigh,请发表您的评论作为答案,我会将其标记为已接受,因为您发现了问题,而我在清理变量引用时碰巧弄对了。
标签: .net coldfusion coldfusion-10