|
General Programming General NinjaScript programming questions. |
|
Thread Tools | Display Modes |
03-29-2009, 03:14 PM | #1 |
Member
Join Date: Jan 2009
Posts: 78
Thanks: 0
Thanked 4 times in 2 posts
|
Workaround to Debug with Visual Studio Express Edition
Hi,
While VS express edition is missing the ability to "attach to process" it still can be done, thx to this post: http://stewartr.blogspot.com/2006/09...al-studio.html What to do? 1) Open Visual Studio. 2) Create new project (I craeted regular console application), let call it NinjaTraderDebug. 3) Save the project and close visual studio. 4) Go to the project directory and open with notepad the NinjaTraderDebug.csproj.user file. 5) Edit it to look like this (the bold lines is what I added, of course you need to put your path to NinjaTrader.exe). <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <PropertyGroup> <StartAction>Program</StartAction> <StartProgram>C:\Program Files\NinjaTrader 6.5\bin\NinjaTrader.exe</StartProgram> </PropertyGroup> </Project> 6) Close NinjaTrader if it is opened. 7) Open the ninjatraderDebug project in VisualStudio. 8) Hit "Play" (F5), this will launch NinjaTrader and will attach to it. 9) Now do sections 1 and 3 from here: http://www.ninjatrader-support.com/H...l?VisualStudio It works for me Yuval. |
|
03-29-2009, 05:44 PM | #2 |
Founder and CEO
Join Date: Nov 2004
Location: Denver, CO, USA
Posts: 11,379
Thanks: 16
Thanked 265 times in 112 posts
|
Thanks for this contribution.
Ray
NinjaTrader Customer Service |
|
08-02-2009, 06:13 PM | #3 |
Junior Member
Join Date: Jul 2009
Posts: 19
Thanks: 0
Thanked 1 time in 1 post
|
After Start Debugging in Visual Studio Express, a new instance of Ninjatrader is spawned. If I try to open Ninjatrader outside VS Express, get error "not allowed to run 2 instances of Ninjatrader". I selected Debug Mode from Ninjatrader instance before opening VS Express. From VS Express' Ninjatrader instance, I connected to my datafeed and selected and ran my strategy from the Strategy Analyzer. I placed a Print statement in my code in the OnBarUpdate() method just for further verification my code is getting executed. Ninjatrader supposedly runs the strategy but I get no feedback from Print statement or see any output from my Drawline calls in my code. I set breakpoints in VS Express but they become inactive after Start Debugging from VS Express. VS Express shows from hovering pointer over breakpoint, "The breakpoint will currently not be hit. No symbols have been loaded for this document." It can't be referring to a symbol in terms of a Ninjatrader instrument/symbol for a chart because I have a chart up in Ninjatrader which is displaying candles. Could it be running the strategy without executing my code? How do I get the breakpoint active?
|
|
08-03-2009, 07:54 AM | #4 |
Member
Join Date: Jan 2009
Posts: 78
Thanks: 0
Thanked 4 times in 2 posts
|
I'm not sure I understand you scenario.
Anyway, you should NOT have 2 ninja instances (see section 6 in my explanation). After you hit F5 and Ninja is launched from VS, go to script editor and mark "Debug Mode" and recompile (this will generate the pdb). When you set a breakpoint it is OK that you get it "hollowed", it depends whether Ninja had already loaded or not you dll. |
|
08-03-2009, 07:58 AM | #5 |
NinjaTrader Product Manager
Join Date: May 2007
Location: Denver, CO
Posts: 17,460
Thanks: 1
Thanked 193 times in 85 posts
|
aascotty,
Unfortunately NT does NOT work with the Express version of VS.
Josh
NinjaTrader Customer Service |
|
08-18-2010, 01:45 PM | #6 |
Senior Member
Join Date: Apr 2009
Posts: 275
Thanks: 5
Thanked 20 times in 10 posts
|
Hi Yuval ,
The workaround works for VS Express 2008 either (I'm using NT7), but adding <PropertyGroup> <StartAction>Program</StartAction> <StartProgram>C:\Program Files\NinjaTrader 7\bin\NinjaTrader.exe</StartProgram> </PropertyGroup> should be done in a file : NinjaTraderDebug.csproj , not NinjaTraderDebug.csproj.user as you and the blog above state. Altering NinjaTraderDebug.csproj.user invalidates the solution. At least that's what's work for me. Happy debugging. |
|
The following user says thank you to xTrader1 for this post: |
|
10-08-2010, 01:01 AM | #7 |
Junior Member
Join Date: Oct 2010
Posts: 1
Thanks: 0
Thanked 0 times in 0 posts
|
Hi,
I just tried debugging NT 7 Beta 22 with Visual Studio 2010 Express edition yesterday night and it worked perfectly. I have just updated the NinjaTraderDebug.csproj (and not NinjaTraderDebug.csproj.user which does not exist) as specified in this thread. Have fun, Olivier. |
|
05-04-2011, 12:39 AM | #8 |
Junior Member
Join Date: May 2011
Posts: 1
Thanks: 0
Thanked 0 times in 0 posts
|
Hello. Thanks for this tip, i will extend it... It's working perfectly even for VS2010 Express. I had combined it with solution based on this template. So when i compile solution, the library with my code is placed to the Custom folder of NT and afterwards the NT is started with this library loaded. Then I can even Pause debugging, make change in code and hitting Continue will recompile my code without restarting NT ! So this way I can use professional development IDE and debugging capabilities without pain Hope this helps somebody too.
|
|
06-19-2011, 01:13 PM | #9 | |
Junior Member
Join Date: Aug 2010
Posts: 18
Thanks: 0
Thanked 0 times in 0 posts
|
Hi FredyC,
i tried your example. But i get error messages like this Quote:
Thanks Eddy |
|
|
11-08-2011, 04:46 PM | #10 |
Member
Join Date: Dec 2008
Location: Kansas City
Posts: 90
Thanks: 0
Thanked 2 times in 2 posts
|
Confirming this procedure still works . Debugger works with breakpoints.
However, type ahead does not seem to be working for me which makes coding in VS Express much less useful (still good for debugging though). Any ideas on what needs to be changed to get type ahead to work in visual studio express C# 2010? Missing a reference somewhere? Does type ahead work in the full VS version? Thanks, kc |
|
01-22-2012, 06:01 PM | #11 |
Junior Member
Join Date: Jan 2012
Posts: 1
Thanks: 0
Thanked 0 times in 0 posts
|
Link http://www.ninjatrader-support.com/H...l?VisualStudio is not working?
Is there an alternative link? Thanks, |
|
01-23-2012, 01:06 AM | #12 |
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 26,180
Thanks: 487
Thanked 1,818 times in 1,761 posts
|
Bertrand
NinjaTrader Customer Service |
|
03-02-2012, 05:23 PM | #13 |
Senior Member
Join Date: Jul 2008
Posts: 295
Thanks: 4
Thanked 10 times in 9 posts
|
I don't develop Microsoft software (I'm more a unix guy), so I can't justify purchasing the whole Visual Studio package just to debug a few NinjaScripts. Therefore, I was really glad to find this thread.
My NinjaTrader coding has gotten complex enough (with custom classes and all) that I need more than Print() to debug anything, especially because Print() doesn't work inside my own classes. Being a veteran programmer who is unfamiliar with Microsoft development tools, I have to ask: How do I actually debug anything with Visual Studio Express? I've followed the instructions in this thread. I got NT7 to attach to Visual C# Express 2010, compiled MyIndicator with Debug Mode enabled, then in Visual C# I went to File->Open File and found MyIndicator.cs, and loaded it. Then what? I can set a breakpoint in my indicator code, but Visual C# attaches a note to it saying "The breakpoint will not be hit. No symbols have been loaded for this document." And of course, when I reload NinjaScripts from the chart displaying my indicator, it isn't executed in the debugger. Stopping debugging also closes NinjaTrader. Any tips to get me started? What step have I missed? Do I need to create a project for my indicator and make similar modifications to the project files? Thanks. -Alex
Last edited by anachronist; 03-02-2012 at 05:26 PM.
|
|
03-02-2012, 05:38 PM | #14 |
Member
Join Date: Sep 2011
Location: Chicago
Posts: 76
Thanks: 9
Thanked 7 times in 7 posts
|
You need to hit F5 (compile) everytime to 'load the symbols'.
Other thing: IMPORTANT: You need to disable breakpoints in VS when you first start debugging. Otherwise, Market Replay will hang. This is the order: (a) start Market Replay at the desired date/time, (b) set up Break points, (c) Run Market Replay. Then it will stop at the desired date/time and code location. Let me know if you have more questions... I also struggled a bit to get this going but now it works great for me. |
|
03-02-2012, 05:52 PM | #15 |
Senior Member
Join Date: Jul 2008
Posts: 295
Thanks: 4
Thanked 10 times in 9 posts
|
Thanks ds1111. I don't notice anything different.
I have two tabs in Visual C#. One is Program.cs, an empty bit of project code described in this thread to attach NinjaTrader. The other tab is my indicator script, call it MyIndicator.cs, which is found in NinjaTrader 7\bin\Custom\Indicator\MyIndicator.cs. I've compiled it in the NT7 editor in Debug Mode. The Program.cs tab contains only this: Code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { } } } If I stop debugging, NinjaTrader closes. If I go to the MyIndicator.cs tab and press F5, NinjaTrader starts up again, and it loads my workspace with my chart that displays my indicator. I thought I'd hit a breakpoint if I right-clicked on my chart and selected "Reload NinjaScript." Is replay mode necessary for debugging? Thanks. Alex
Last edited by anachronist; 03-02-2012 at 05:56 PM.
|
|
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
NT & Visual Studio C# Express 2008 | Tight Face | Installation and Licensing | 1 | 10-23-2008 02:50 AM |
Visual C# Express Edition 2008 vs. NinjaScript editor | Elliott Wave | General Programming | 4 | 04-07-2008 11:33 PM |
What Versions of Visual Studio are supported? | zoltran | Historical NinjaTrader 6.5 Beta Threads | 3 | 02-19-2008 08:00 AM |
Using Visual Studio debugger | SuzyG | General Programming | 1 | 12-21-2006 08:57 PM |
Debugging using Visual Studio | guym | Indicator Development | 2 | 11-28-2006 01:41 AM |