[英]InvalidCastException When using ActiveX in C# project
尊敬的所有交易員和API專家:
先感謝您。
背景:
問題:
一種。 第1步:從TWSLib繼承類IContract的接口,我的代碼在此處為圖片,構造函數專用於AUD.USD: 忙碌的貓兒http://i.minus.com/iyG7RLuSGxiEl.jpg
如您所見,我已將私有對象_combolLegs更改為私有TWSLib.IComboLeg _comboLegs
b。 步驟2:我也將IComboleg和IUpdateComp繼承到ComboLeg和UpdateComp,並且由於它們與AUD.USD外匯交易無關,所以我沒有為其分配任何值。
C。 現在,我創建一個合同實例,並嘗試分配所需的所有外匯合同信息並提交查詢。 忙碌的貓http://i.minus.com/iXvgbSsp4MbYz.jpg
d。 這是一個運行時錯誤。 請在此處查看圖片: 忙碌的貓http://i.minus.com/ifFxdfnyvfKF9.jpg
看來我創建的合同實例無法被api接受為正式的IContract實例。 任何.NET專家的想法嗎?
再次非常感謝,
謙虛的學習者。
文豪
編輯
關於IContract的細節我得到的所有沙發
//Try changing the way that you implement the Interface / Clase where you have
// -- var auduse = new Contract();
//depending on boxing and unboxing from this point try to reverse it and do the following
IContract iaudUse = new Contract();
//then you would use iaudUse. what ever method in the Interface that you are wanting to use.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.