Using cAlgo.API dll in custom dll
Using cAlgo.API dll in custom dll
11 Mar 2014, 02:58
Sorry for the double post but on second thought I think it made sense to create a separate thread rather than adding to an existing one.
I am having the same problem as Hyperloop mentioned in this thread /forum/cbot-support/1739 and since I am also new to C#, setting the correct references and objects is still hit or miss for me. As I believe Hyperloop was trying to do, I am trying to create a dll to hold methods that I will use in different robots. I have created other dlls that are working fine but I am struggling with using cAlgo,API in my custom dll.
I am working in VS 2010. I have added cAlgo.API in References (for this project) so I get IntelliSense and I can view it fine through the Object Browser. I also have no problem using VS2010 to write cBots in general. That part is working great. It is creating a custom dll that uses cAlgo.API dll that has me stumped.
The code I have so far for my custom dll is this:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using cAlgo.API; namespace cAlgoGeneralMethods { public class General { private int GetPosCnt() { int iPosCnt; iPosCnt = Positions.Count; return iPosCnt; } } }
As anyone who knows C# and cAlgo well (I don't) the line
iPosCnt = Positions.Count;
will not work and I would get the same error as Hyperloop got, "An object reference is required for the non-static field, method, or property".
I have looked at the responses that Hyperloop got but I have not found a specific example of how to get it to work. I would very much appreciate a quick sample of what I need to add to get cAlgo.API objects/methods recognized in my custom dll.
Regards,
Aim
Replies
AimHigher
11 Mar 2014, 20:14
Added a follow up question here /forum/cbot-support/1739?page=2#13
@AimHigher
Spotware
11 Mar 2014, 09:24
/forum/cbot-support/1739?page=2
@Spotware