在 C# 项目中使用 ActiveX 时 InvalidCastException
亲爱的所有交易者和 API 专家,
先谢谢你们。
背景:
- Visual Studio 2010、C#语言、ActiveX OCX API作为项目参考。
- 依次使用reqAccountUpdate等API提供的方法,利用事件接收账户更新信息。
问题:
- 现在我需要有关一种特定金融工具的数据,例如外汇对: AUD.USD 。
一个。步骤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
这是一个运行时错误。请检查这里的图片: 一只忙碌的猫 http://i.minus.com/ifFxdfnyvfKF9.jpg
我创建的合约实例无法被 api 接受为正式的 IContract 实例。 .NET 专家有什么想法吗?:)
再次感谢
谦虚的学习者。
文浩
编辑
关于IContract所有我到目前为止得到的细节
Dear all trader and API Gurus,
Thank you in advance.
Background:
- Visual Studio 2010, C# Language, ActiveX OCX API as reference of project.
- Successively to use the method provided by API like reqAccountUpdate and use the event to receive information about account update.
Issue:
- Now I would like to require data about one specific financial instrument like a forex pair: AUD.USD .
a. Step 1: Inherit the interface of class IContract from TWSLib my Code is here as a picture and the constructor is specific for AUD.USD:
a busy cat http://i.minus.com/iyG7RLuSGxiEl.jpg
As you can see that I have change the private object _combolLegs to private TWSLib.IComboLeg _comboLegs
b. Step 2: I also inherit the IComboleg and IUpdateComp to ComboLeg and UpdateComp and I do not assign any value to them since they are not related
to the the AUD.USD forex trading.
c. Now I create a instance of contract and try to assign all information forex contract required for and submit my query.
a busy cat http://i.minus.com/iXvgbSsp4MbYz.jpg
d. it is a runtime error. Please check the picture here:
a busy cat http://i.minus.com/ifFxdfnyvfKF9.jpg
It seems like the contract instance I created could not be accepted by the api as formal IContract instance. Any idea from any .NET gurus?:)
Thanks lot in advance again,
Humble learner.
Wenhao
Edit
about the detail of IContract all I got sofar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)