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

Help adding a reference

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

    Help adding a reference

    I have created a simple class using my dotnet CLI like this and added some functions I want to reference:
    Code:
    new classlib -o SjFunctions
    I then built it like this:
    Code:
    dotnet build
    I have followed the instructions in this article:


    However, after I add my using statement and right click the NT editor and add the reference, I get this error:
    Code:
    The type 'System.Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
    I opened my .csproj file and the target framework is netstandard2.0. I tried changing this to this but it did not help:
    Code:
    netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51
    Here is a simple example of the structure of my class:
    Code:
    using System;
    using System.IO;
    using System.Text;
    using System.Net;
    using System.Net.Http;
    using System.Net.Sockets;
    
    namespace SjFunctions
    {
        public class Sj{
            public void Put(string path, string content){
                using (FileStream fs = File.Create(path))     
                {    
                    Byte[] data = new UTF8Encoding(true).GetBytes(content);    
                    fs.Write(data, 0, data.Length);    
                }              
            }        
        }
    }
    Any help would be appreciated.

    #2
    Hello swcooke,

    It looks like you are not using .NET framework, you are using dotnet core/standard which is not the same. The error notes you are using netstandard which is not used in NinjaTrader.

    To make an assembly you would need to use visual studio and create a .NET Framework 4.8 or less library (.dll). All other versions of C# will not work with NinjaTrader.

    You can find some infomration which describes netcore and .net framework here: https://www.c-sharpcorner.com/articl...-and-net-core/

    I look forward to being of further assistance.
    Last edited by NinjaTrader_ChelseaB; 06-07-2021, 11:40 AM.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Aviram Y, Today, 05:29 AM
    0 responses
    2 views
    0 likes
    Last Post Aviram Y  
    Started by quantismo, 04-17-2024, 05:13 PM
    3 responses
    25 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by ScottWalsh, 04-16-2024, 04:29 PM
    7 responses
    34 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by cls71, Today, 04:45 AM
    0 responses
    6 views
    0 likes
    Last Post cls71
    by cls71
     
    Started by mjairg, 07-20-2023, 11:57 PM
    3 responses
    217 views
    1 like
    Last Post PaulMohn  
    Working...
    X