問題描述
對于某些背景,這與 將 IEnumerable 變量從冷融合.我已將代碼更改為使用列表,并取得了進展,但在使用 .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.
首先,我有一個包含以下 VideoWallEvent.cs 文件的 .dll:
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) />
所以我現在需要幫助來弄清楚如何正確地將這個 List 推送到 Set_Events() 方法中.
So I now need help figuring out how to properly push this List into the Set_Events() method.
推薦答案
(來自評論)
信不信由你,這只是一個組裝路徑問題.你必須使用匯編列表中的兩個文件,而不僅僅是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 中的列表調用 .NET 方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!