Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Duplicate Function Name Error when using Newtonsoft

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • jeronymite
    replied
    rezik I have not encountered that error before. Some things to investigate:
    • Ensure the DLL is for .Net Framework 4.8
    • Try copying it to the relevant NinjaTrader program folder (e.g. for 64-bit: C:\Program Files (x86)\NinjaTrader 8\bin64)
    Thanks.

    Leave a comment:


  • rezik
    replied
    jeronymite I'm curious if this is the problem you ran into with the Memory issue. I added the nugent System.Memory to the custom folder and added the reference. It compiles fine, but when running the serialize from JSON I'm getting this.

    Error on calling 'OnBarUpdate' method on bar 1135: Could not load file or assembly 'System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.

    Is this also what you encountered? Maybe I'm doing something wong.

    Leave a comment:


  • jeronymite
    replied
    For those who find the System.Text.Json approach useful, to ensure you use the latest version (rather than rely on the version provided in any NT8 distribution, given it may not always be included in NT kits), it is best to know where to obtain the dll from its source.

    The dll is available through the Microsoft-supported NuGet site. If you have NuGet, you will find this straightforward. If you do not, NuGet is relatively easy to use, but even without it, you can easily obtain the dll:
    1. The NuGet page for the System.Text.Json package: https://www.nuget.org/packages/System.Text.Json
    2. You can download the latest package using the "Download package" link in the right margin link list
    3. The filename will be similar to system.text.json.6.0.3.nupkg
    4. If you are familiar with NuGet, install the package
    5. If you do not have (or do not want to have) NuGet, use an UnZip program (e.g. 7-Zip) to open the file
    6. Within the file, the dll can be found in the lib folder, and then in the net461 folder (there are other folders in lib with versions that can be ignored)
    7. Extract the System.Text.Json.dll file to the NinjaTrader 8\bin\Custom folder (or elsewhere if you prefer) and add an appropriate reference in NT8
    8. You should then be able to use all the functionality in the dll
    Depending on what functionality is used, there may be dependencies that require additional NuGet (or other) packages. For example, I also need the NuGet System.Memory package. Other NuGet packages follow the same principles above to obtain them.

    Thanks.
    Last edited by jeronymite; 04-24-2022, 06:25 PM. Reason: Additional information

    Leave a comment:


  • Bobin
    replied
    Thank you Chelsea, this worked like a charm

    Leave a comment:


  • NinjaTrader_ChelseaB
    replied
    Hello Bobin,

    I've looked into this and found a suggested workaround.

    Remove reference to Newtonsoft.dll

    Exit NinjaTrader
    Open the config.xml file
    Add the following line under <References>
    <string>netstandard.dll</string>
    Save and now you should be able to compile

    When exporting, select References and select the netstandard reference.

    Leave a comment:


  • Bobin
    replied
    Originally posted by jeronymite View Post
    I had a number of similar issues with Newtonsoft when NT 8.0.25.0 was released. Previously working code failed to compile. After a bit of testing, I was able to avoid Newtonsoft altogether and instead use System.Text.Json.dll found in the NinjaTrader Program Files bin (or bin64) folder. It also allowed me to simplify my code a little. YMMV.

    Thanks.
    Thank you, it worked
    Last edited by Bobin; 04-19-2022, 09:35 AM.

    Leave a comment:


  • jeronymite
    replied
    I had a number of similar issues with Newtonsoft when NT 8.0.25.0 was released. Previously working code failed to compile. After a bit of testing, I was able to avoid Newtonsoft altogether and instead use System.Text.Json.dll found in the NinjaTrader Program Files bin (or bin64) folder. It also allowed me to simplify my code a little. YMMV.

    Thanks.

    Leave a comment:


  • hedgeplay
    replied
    Further .. Newtonsoft might be the easiest of dll dependencies to fix. replace that earlier Newtonsoft dll with the current version 13.0xxx and then figure out how (like recompile all dependencies to NETv4.8 and update every dependent reference mention of Newtonsoft to v13.xxx ) to stop the offending dll that pulled in the wrong version of Newtonsoft today from pulling in the wrong version again every day or so....

    Hedge
    Last edited by hedgeplay; 04-09-2022, 05:20 PM.

    Leave a comment:


  • hedgeplay
    replied
    Hi Bobin..

    However, I now get another error that the type "System.Object" could not be found due to a missing "netstandard" assembly.
    NT8 was compiled by NET Framework v4.8 and will not open Dlls compiled to NetStandard or any of dll dependencies compiled to NetStandard.

    So need to recompile / maybe rework your code for Netv48 .. or work through upgrading or replacing Dll dependencies with those compiled for Netv48 rather than NetStandard.

    As an example.. I am running with dlls with dependencies on other dlls I had to recompile with NETv4.8 or replace those dependent dlls with alternatives.

    Hedge.

    Leave a comment:


  • Bobin
    replied
    I tried to reference the Newtonsoft dll in the bin64 folder. The initial error is now gone.
    However, I now get another error that the type "System.Object" could not be found due to a missing "netstandard" assembly.
    This is very odd, because the dll is used by NinjaTrader itself, right?

    Leave a comment:


  • Bobin
    started a topic Duplicate Function Name Error when using Newtonsoft

    Duplicate Function Name Error when using Newtonsoft

    I use Newtonsoft in my project for json's.
    It works fine, but when I export my project to an Add-On and try to import it on another PC, then I get an error that there is a duplicate function name.
    After I remove Newtonsoft and export/import the project again, then I don't get an error.

    How can I fix it?

Latest Posts

Collapse

Topics Statistics Last Post
Started by GLFX005, Today, 03:23 AM
0 responses
1 view
0 likes
Last Post GLFX005
by GLFX005
 
Started by XXtrader, Yesterday, 11:30 PM
2 responses
11 views
0 likes
Last Post XXtrader  
Started by Waxavi, Today, 02:10 AM
0 responses
6 views
0 likes
Last Post Waxavi
by Waxavi
 
Started by TradeForge, Today, 02:09 AM
0 responses
12 views
0 likes
Last Post TradeForge  
Started by Waxavi, Today, 02:00 AM
0 responses
2 views
0 likes
Last Post Waxavi
by Waxavi
 
Working...
X