2
對於某些背景,這與Passing IEnumerable Variables into .NET from ColdFusion有關。我改變了代碼來使用列表,並取得了進展,但在使用.NET和ColdFusion的簡單數據類型以外的其他任何東西時,仍然會遇到障礙。所以這是當前的問題。未找到方法使用ColdFusion列表調用.NET方法
首先,我有一個.dll具有以下VideoWallEvent.cs文件:
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,我已經生成的代理罈子,運行以下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
方法並通過列表會拋出以下錯誤:
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()方法。
我很好奇,想知道你會得到什麼,如果你叫 –
我弄不明白。 –
我想知道DotNetProxy是否錯誤地設置了Set_Events()增變器。我想知道如果你在施工過程中用一個空的List初始化Events屬性會有什麼不同。 –