Visual Studio Community (2026) > Best Practice for Isolating Custom Code

I have created a solution and added the “NinjaTrader.Custom” project. I have also created a separate class lib project in the solution (targeting net48) - and have most of my custom code there. I have tried to consume this assembly from the “NinjaTrader.Custom” project, via a Project Reference. It builds fine in VS. However … When building via Ninja, it does not see the dependency. When I add the reference in Ninja to the dll (via the Ninja Editor), it corrupts Ninja - and I have to reinstall NinjaTrader and start all over.

Then … I tried NOT adding the project reference in VS - and directing the custom class lib build output to the “bin\custom” folder (as specified in a Ninja doc I was reading). Now … If I make changes in custom class lib (in VS), the solution build fails - because NinjaTrader app has a lock on the custom dll. It’s very inconvenient to have to close NinjaTrader anytime I want to make changes and test.

Question:
What is the best practice for isolating code in a separate assembly?

Have you asked the AI tools? Tell it to go on the internet and cosume all the forum threads and ninjascript developer documentation, and you’ll see the light at the end of the tunnel.

1 Like

It is true that NT will keep your assembly loaded once you use it for the first time, so then you can’t overwrite it. You could perhaps have a two-layer approach where NT references an “outer” assembly, and the outer one reference counts and unloads the inner one when there are no refs and loads it again when a ref appears, then you could do something like close the workspace, recompile, and reopen it. NT only knows about the outer one, and keeps it loaded, while you iterate on the inner one. Just a thought.

I suppose I should say, for my own part, I just reload NT. I like to have clean tests that all have the same starting point. But, that having been said, if I found myself doing external compiles hundreds of times a day, I would probably do something like the above as a way to increase my iteration speed.