Fix NinjaScript errors in NinjaTrader 8 (CS0012, import failed, duplicate method names)
Your indicator will not compile. An import fails. NinjaTrader will not finish opening. The message on screen rarely says what is really wrong, and one stray file can block every NinjaScript compile on the PC. This guide covers the eight errors we see most often, what each one means in plain words, and how to fix it by hand. For each, there is also the free tool that does the work for you.
The 8 errors at a glance
Find your message, jump to the fix. Or skip the reading: Fix & Optimize reads NinjaTrader’s own log, finds what is blocking it and fixes it for free.
- CS0012 … assembly not referenced (netstandard)
Every compile fails and imports are refused. - Import failed / duplicate method names / already contains a definition
OneDrive copies of files make NinjaTrader see everything twice. - Could not load file or assembly
A file NinjaTrader expects is missing, often after a half-finished import. - Import errors that mention a path
The zip cannot be read, or sits online-only in OneDrive. - Access to the path … mpImport is denied
The import working folder is marked Read-only. - Missing tmpImportBackup folder
NinjaTrader closes during an import. - NinjaTrader will not finish starting
A third-party add-on is waiting behind the splash screen. - An item with the same key has already been added
Two templates hold the same name.
Fix these for free: download Fix & Optimize
Free with a free account and a confirmed email. Nothing is deleted, and every change can be put back.
NinjaScript has errors, and my indicator will not compile or import
NinjaTrader builds all your custom indicators, strategies and add-ons together, as one set. So one broken file, even one you never use, makes the whole build fail. That is why a brand new indicator can fail with an error that names a completely different file.
- Open the NinjaScript Editor (New > NinjaScript Editor), press F5 and read the list of errors at the bottom.
- Look at the file names in that list. If they are not the indicator you were trying to add, the cause is elsewhere. Match the message to one of the sections below.
- Fix the cause, press F5 again, and repeat until the list is empty.
Fix & Optimize reads NinjaTrader’s own log of the last build, finds what is blocking it, and fixes it for free. See the sections below for each case.
CS0012: the type is defined in an assembly that is not referenced (‘netstandard’)
What you see
In the NinjaScript Editor, after F5 or after an import:
CS0012: The type ‘Object’ is defined in an assembly that is not referenced. You must add a reference to assembly ‘netstandard’.
What it means
The NinjaTrader build needs a Windows file called netstandard.dll to understand some add-ons, and it cannot find it in its list of references. Until that is fixed, every compile fails, and imports are refused.
The usual cause
A third-party add-on was built with a newer kind of library (.NET Standard), and it was linked into NinjaTrader’s reference list. Some repair tools add such links on their own and can cause this. We have seen it after a tool added many extra links to the list.
Fix it by hand
- Open the NinjaScript Editor, right-click inside the code, and choose References.
- Click Add and browse to C:\Windows\Microsoft.NET\Framework64\v4.0.30319\netstandard.dll. This file exists on Windows with .NET Framework 4.7.1 or newer.
- Press OK, then F5 to compile. Then import your file again.
Fix it free
Fix & Optimize checks the reference list when a build fails with this error and takes back the links that cause it, after backing up your Config.xml. It is free.
“Import failed … duplicate method names” or “already contains a definition”
What you see
Tools > Import fails with a message that the NinjaScript archive “may contain duplicate method names”. In the NinjaScript Editor you may see a long list of errors that say a type or namespace “already contains a definition for” a name. Sometimes a product you had before an update is simply gone from NinjaTrader.
What it means
NinjaTrader is seeing every indicator, strategy or add-on twice. When a name exists twice, no build can succeed.
The usual cause
Copies of files made by OneDrive. When your NinjaTrader 8 folder lives in OneDrive, and OneDrive syncs a file that is open on another PC, it saves a second copy with a different name, such as one ending in -DESKTOP-xxxx, in your PC’s name, or in ” – Copy” or ” (1)”. NinjaTrader loads every .dll in the bin\Custom folder, so the copy is loaded as if it were another add-on. The copies are often of NinjaTrader.Custom.dll itself, or of a trade copier or other add-on’s files.
Fix it by hand
- Close NinjaTrader completely.
- Open Documents\NinjaTrader 8\bin\Custom in File Explorer. Search that folder, subfolders included, for names ending in -DESKTOP-, your PC’s name, ” – Copy” or ” (1)”.
- Move those copies to a folder outside NinjaTrader, such as your Desktop. Do not move the original file that has the same name without the ending.
- Start NinjaTrader and press F5 in the NinjaScript Editor.
- If the product still will not import, open Tools > Remove NinjaScript Assembly, remove the older compiled entry for that product, restart NinjaTrader, then import the zip again.
The lasting fix is to move NinjaTrader’s folder out of OneDrive so that it stops making copies.
Fix it free
Fix & Optimize finds OneDrive’s copies, including ones named after your PC, moves them into a set-aside folder you can put back, and can move NinjaTrader’s folder out of OneDrive. It is free.
“Could not load file or assembly …”
What you see
A message such as: Could not load file or assembly ‘SomeName, Version=1.0.0.0’ or one of its dependencies. It can show as an error box when NinjaTrader starts, in the NinjaScript Editor, or as NinjaTrader closing a few seconds after you log in.
What it means
NinjaTrader was told to use a file, and the file is not there. The build or a chart is still pointing at it.
The usual cause
- An import that stopped halfway. The code file is in NinjaTrader, but the compiled .dll that goes with it never arrived. This is common after NinjaTrader closes or crashes during an import or an in-app update.
- An add-on’s files that were removed or set aside by hand while NinjaTrader’s build still depended on them.
Fix it by hand
- Close NinjaTrader. Read the file name in the message.
- If it is a file from a product you downloaded, find the .dll in that product’s original zip and copy it into Documents\NinjaTrader 8\bin\Custom. Do not overwrite a file that is already there.
- If you moved the file away yourself on purpose, put it back, start NinjaTrader, then remove the add-on properly with Tools > Remove NinjaScript Assembly.
- For a half-finished import of one product: remove its old entry under Tools > Remove NinjaScript Assembly, restart NinjaTrader, import the zip again, answer Yes to authorize, and restart again.
Fix it free
Fix & Optimize reads the file name from NinjaTrader’s log, looks for a copy on your PC (Desktop, Documents, Downloads, OneDrive, even inside zips), and with your Yes copies it back into place. It never overwrites a file. It is free.
Import errors that mention a path
What you see
Tools > Import fails, and the message talks about a path: the path is too long, contains illegal characters, is “not of a legal form”, cannot be found, or the zip cannot be read.
What it means
NinjaTrader could not open the zip file or could not write into its own folders at the location it was given.
The usual cause
- The zip sits in a OneDrive folder and was never fully downloaded to the PC (“online only”).
- The zip was opened straight from the browser or from inside a zip window, so it lives in a temporary place that no longer exists when NinjaTrader reads it.
- The zip is damaged or only half downloaded.
- You imported a file taken out of the zip instead of the zip itself.
- The folder path is very long.
Fix it by hand
- Save the zip into your Downloads folder under the name it was downloaded with. Do not unzip it. Import that .zip file.
- If the file is in OneDrive, right-click it and choose “Always keep on this device”, or copy it to Downloads first.
- If the zip will not open, download it again.
- If your NinjaTrader folder path is very long (over about 150 characters), shorten the folder names above it.
Fix it free
Fix & Optimize works out which of these it was, and tells you the one step that applies, such as where to save the zip and import it again. For a path that is too long it points you to the help chat. It is free.
“Access to the path …\tmp\Import … is denied”
What you see
An import fails with: Access to the path ‘C:\Users\you\Documents\NinjaTrader 8\tmp\Import\’ is denied. Sometimes NinjaTrader closes at the same moment.
What it means
NinjaTrader uses a working folder called tmp\Import to unpack what you import, and then it tidies the folder up. Windows will not let it.
The usual cause
The tmp\Import folder itself is marked Read-only. This is most common when the NinjaTrader 8 folder is in OneDrive, which can set that flag. We measured it: a Read-only mark on that folder produces exactly this message, with the slash at the end of the path.
Fix it by hand
- Close NinjaTrader.
- In File Explorer, open Documents\NinjaTrader 8\tmp, right-click the Import folder and choose Properties.
- Untick Read-only, then Apply (choose to apply it to the folder, subfolders and files if asked).
- Check that a folder named Backup exists inside Import. Create it if it does not. Start NinjaTrader and import again.
Fix it free
Fix & Optimize finds the Read-only mark, clears it, makes sure the Backup folder is there, and tells you when the import folder was the problem. It is free.
Missing tmp\Import\Backup folder (NinjaTrader closes during an import)
What you see
You start an import and NinjaTrader closes, or the import stops, with nothing useful on screen. In NinjaTrader’s log there is an error that a folder named Backup could not be found.
What it means
While importing, NinjaTrader expects the tmp\Import\Backup folder to exist. When it is missing, the import cannot finish.
The usual cause
NinjaTrader’s own clean-up removed the Backup folder, often right after the “access denied” error above. The two usually come together, on PCs where NinjaTrader’s folder is in OneDrive.
Fix it by hand
- Close NinjaTrader.
- Open Documents\NinjaTrader 8\tmp. If there is no Import folder, create one. Inside Import, create a folder named Backup.
- Clear the Read-only mark on Import as described in the section above, then import again.
- If it fails again, move NinjaTrader’s folder out of OneDrive. That is the lasting fix.
Fix it free
Fix & Optimize creates the missing folder and clears the Read-only mark in the same step. It is free.
NinjaTrader will not finish starting: a third-party add-on is waiting behind the splash screen
What you see
You log in and NinjaTrader just spins on the splash screen. It may sit there for a minute or more, then never show your workspace. Nothing says why.
What it means
Some add-ons, often old trade copiers, open their own window while NinjaTrader loads, for example to ask you to authorize them. That window can sit hidden behind the splash screen, and NinjaTrader waits on it. In a case we measured, each start paused for exactly 60 seconds on one add-on file and never reached “Restoring workspace”.
The usual cause
An old add-on that came back, for example from an older copy of the NinjaTrader folder in OneDrive, and that wants an answer before it lets NinjaTrader continue.
Fix it by hand
- While NinjaTrader is spinning, press Alt+Tab. Look for a window you do not recognise, with the name of an add-on or a trade copier. Answer or close it.
- If NinjaTrader still hangs, close it. In Documents\NinjaTrader 8\bin\Custom, look for a group of files from the same company, with the same name start and the same date. Move them to a folder outside NinjaTrader.
- If the add-on is also installed in Windows, remove it in Settings > Apps.
- Start NinjaTrader again.
What Fix & Optimize does today
Fix & Optimize is free. It reads NinjaTrader’s log for starts that are held up after an add-on loads, and it records which add-on it was in your report. It does not yet show you the window or move that add-on’s files for you, so follow the steps above, and the help chat can read your report and point you to the add-on.
“An item with the same key has already been added” (duplicate templates)
What you see
Error boxes when NinjaTrader starts, such as: Unable to load risk template … An item with the same key has already been added. It can also appear for ATM strategy and other templates. The same text can appear when an import fails.
What it means
NinjaTrader keeps a list of templates and each one must have its own name. It reads the name from inside the file, not from the file name. Two files with the same name inside them make it stop.
The usual cause
A template file that was copied in File Explorer, or by OneDrive, so that two files hold the same name. The file name changed but the name inside the file did not.
Fix it by hand
- Close NinjaTrader.
- Open Documents\NinjaTrader 8\templates, then the folder named in the error (for example Risk).
- Look for file names that end in -DESKTOP-xxxx, your PC’s name, ” – Copy” or ” (1)”. Open a suspect in Notepad and compare the Name line inside it with the other file’s.
- Move the copy to a folder outside NinjaTrader. Do not move a template that NinjaTrader makes itself, such as the Default ones, because NinjaTrader will make it again.
- Start NinjaTrader.
- If the error appears when you import a product, also see the “duplicate method names” section above.
Fix it free
Fix & Optimize finds templates that share a name and changes the name inside the copy to match its file name, so nothing is deleted. It is free.
Frequently asked questions
Is Fix & Optimize really free?
Yes. Fixing what stops NinjaScript from compiling, or stops our products from getting in, loading and running, is free. You need a free account on this site with a confirmed email address, and you do not need to have bought anything.
Does it delete my files?
No. When Fix & Optimize changes something, it moves the file into a set-aside folder and keeps a way to put it back. Nothing is deleted.
Does NinjaTrader need to be closed?
Files are only moved while NinjaTrader is closed, because NinjaTrader rewrites some of them when it exits. Fix & Optimize closes NinjaTrader as part of a repair, starts it again and checks the result.
Will it help if my problem is not on this list?
It reads NinjaTrader’s log to find what is wrong, and it sends you a plain report of what it found. If it cannot fix something, send the report through the help chat on this site and we will take it from there.
Does it work with other companies’ add-ons?
Yes. The OneDrive copies, the path errors and the missing-file checks are not tied to our products. Fix & Optimize does not delete or change another company’s add-on without asking you first.
Still stuck? Let the tool find it.
Fix & Optimize checks all eight of these in one run and fixes what it finds, free.