dll function call.
Created at 15 May 2014, 22:29
LA
dll function call.
15 May 2014, 22:29
Could someone tell me what i am doing wrong. I am trying to use gget() function but the bot crashes every time: 15/05/2014 19:20:34.394 | Crashed in OnTick with DllNotFoundException: Unable to load DLL 'sample.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E) It is a c++ dll. Here is the code: using System; using System.Linq; using cAlgo.API; using cAlgo.API.Indicators; using cAlgo.API.Internals; using cAlgo.Indicators; using System.Runtime.InteropServices; class Test { [DllImport("sample.dll")] public static extern int gget(out double[] c); } namespace cAlgo { [Robot(TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class NewcBot : Robot { [Parameter(DefaultValue = 0.0)] public double Parameter { get; set; } protected override void OnStart() { // Put your initialization logic here } protected override void OnTick() { double[] arr; Test.gget(out arr); Print(arr[0]); // Put your core logic here } protected override void OnStop() { // Put your deinitialization logic here } } }
Replies
Laszlo_Tormasi
16 May 2014, 14:19
RE:
Spotware said:
You can try to specify absolute path to your dll instead of relative one. For example:
class Test { [DllImport(@"C:\sample.dll")] public static extern int gget(out double[] c); }Probably you also need to specify AccessRigths.FullAccess instead of AccessRights.None
Many thanks, it is working now.
@Laszlo_Tormasi
raul.gherman
29 Jul 2017, 11:36
if you install your library to GAC, no need for absolute path
@raul.gherman
... Deleted by UFO ...
Spotware
16 May 2014, 09:26
You can try to specify absolute path to your dll instead of relative one. For example:
Probably you also need to specify AccessRigths.FullAccess instead of AccessRights.None.
@Spotware