Hi, got error when trying dex2 examples. Everything is OK when using API from within Excel, but getting "The access to field(s) denied" error from Dex2 C# sample application. Why it happens? See the screenshot below.
Hi, got error when trying dex2 examples. Everything is OK when using API from within Excel, but getting "The access to field(s) denied" error from Dex2 C# sample application. Why it happens? See the screenshot below.
You are trying to use the new set of fields (TR.<fieldname>) with the old initialisation routine. In order for this to work, you need to change the CreateDex2Mgr() initialisation routine.
Instead of:
MyDex2Cookie = MyDex2Mgr.Initialize();
You need to have:
MyDex2Cookie = (MyDex2Mgr as IDex2Mgr2).Initialize(DEX2_MetadataCaller.DE_MC_ADC_UNKNOWN);
@Zhenya Kovalyov - Can you please post the new code for VB .NET as well (please also include changes to declarations etc if necessary)? I've modified the Dex2 VB .NET sample application for my own purposes but now ran across the same error. Thank you
@vlscout
The correct initialisation routine for VB .NET will be the following:
_dexCookie = DirectCast(_dexMgr, Dex2.IDex2Mgr2).Initialize(Dex2.DEX2_MetadataCaller.DE_MC_ADC_UNKNOWN)
Full sample below:
Private _api As EikonDesktopDataAPILib.EikonDesktopDataAPI Private _dexMgr As Dex2.Dex2Mgr Private _dexCookie As Long Private _rdata As Dex2.RData Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load _api = New EikonDesktopDataAPILib.EikonDesktopDataAPI AddHandler _api.OnStatusChanged, AddressOf Api_OnStatusChanged _api.Initialize() End Sub Private Sub Api_OnStatusChanged(ByVal eStatus As EikonDesktopDataAPILib.EEikonStatus) If eStatus = EikonDesktopDataAPILib.EEikonStatus.Connected Or eStatus = EikonDesktopDataAPILib.EEikonStatus.LocalMode Then _dexMgr = _api.CreateDex2Mgr() _dexCookie = DirectCast(_dexMgr, Dex2.IDex2Mgr2).Initialize(Dex2.DEX2_MetadataCaller.DE_MC_ADC_UNKNOWN) _rdata = _dexMgr.CreateRData(_dexCookie) AddHandler _rdata.OnUpdate, AddressOf RData_OnUpdate With _rdata .InstrumentIDList = "TRI.TO" .FieldList = "TR.ISIN" .Subscribe(False) End With End If End Sub Private Sub RData_OnUpdate(ByVal dataStatus As Dex2.DEX2_DataStatus, ByVal [error] As Object) Dim i As Long, j As Long For i = LBound(_rdata.Data, 1) To UBound(_rdata.Data, 1) For j = LBound(_rdata.Data, 2) To UBound(_rdata.Data, 2) Debug.Print(_rdata.Data(i, j)) Next j Next i End Sub