Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Self referencing loop detected for property with type ...

Self referencing loop detected for property with type ...

Scheduled Pinned Locked Moved C#
helpquestionjson
6 Posts 3 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AtaChris
    wrote on last edited by
    #1

    The message above comes from the following code:

    public abstract class Indicator : ExtendedIndicator
    {
    [global::Newtonsoft.Json.JsonIgnoreAttribute]
    protected ITradingManager? TradingManager { get; }
    }

    class MyTradingManager
    {
    public ITradingManager _tradeManager;

      public MyTradeManager(ITradingManager argTradingManager)
      {
       \_tradeManager = argTradingManager;
      }
    

    }

    internal class SampleIndicator : Indicator
    {
    MyTradeManager _tradingManager;

      public SampleIndicator ()
      {
           \_tradingManager = new(TradingManager ); <- Here the problem occurs !!!
      }
    

    }

    Any Ideas why I get the error message in the title of this question ?

    Richard Andrew x64R D 2 Replies Last reply
    0
    • A AtaChris

      The message above comes from the following code:

      public abstract class Indicator : ExtendedIndicator
      {
      [global::Newtonsoft.Json.JsonIgnoreAttribute]
      protected ITradingManager? TradingManager { get; }
      }

      class MyTradingManager
      {
      public ITradingManager _tradeManager;

        public MyTradeManager(ITradingManager argTradingManager)
        {
         \_tradeManager = argTradingManager;
        }
      

      }

      internal class SampleIndicator : Indicator
      {
      MyTradeManager _tradingManager;

        public SampleIndicator ()
        {
             \_tradingManager = new(TradingManager ); <- Here the problem occurs !!!
        }
      

      }

      Any Ideas why I get the error message in the title of this question ?

      Richard Andrew x64R Online
      Richard Andrew x64R Online
      Richard Andrew x64
      wrote on last edited by
      #2

      You didn't post the whole error message, did you? Please post the entire thing.

      The difficult we do right away... ...the impossible takes slightly longer.

      A 1 Reply Last reply
      0
      • A AtaChris

        The message above comes from the following code:

        public abstract class Indicator : ExtendedIndicator
        {
        [global::Newtonsoft.Json.JsonIgnoreAttribute]
        protected ITradingManager? TradingManager { get; }
        }

        class MyTradingManager
        {
        public ITradingManager _tradeManager;

          public MyTradeManager(ITradingManager argTradingManager)
          {
           \_tradeManager = argTradingManager;
          }
        

        }

        internal class SampleIndicator : Indicator
        {
        MyTradeManager _tradingManager;

          public SampleIndicator ()
          {
               \_tradingManager = new(TradingManager ); <- Here the problem occurs !!!
          }
        

        }

        Any Ideas why I get the error message in the title of this question ?

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        Why do you even have that line in the constructor? It doesn't even make sense. The "SampleIndicator()" constructor doesn't take any arguments, so are you trying to create a new instance of TradingManager for it to hold onto? The code, as it is now, doesn't make sense at all.

        Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak

        A 1 Reply Last reply
        0
        • D Dave Kreskowiak

          Why do you even have that line in the constructor? It doesn't even make sense. The "SampleIndicator()" constructor doesn't take any arguments, so are you trying to create a new instance of TradingManager for it to hold onto? The code, as it is now, doesn't make sense at all.

          Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak

          A Offline
          A Offline
          AtaChris
          wrote on last edited by
          #4

          With the following code:

          public SampleIndicator ()
          {
          _tradeManager = new(TradingManager ); <- Here the problem occurs !!!
          }

          I want to "inject" TradingManager into my own object _tradeManager which already works as expectet. The problem is the errors message I get from the logging window of the app that uses my plugin dll. Unfortunaltely I do not have access to the source code of that app, only to my dll.

          D 1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            You didn't post the whole error message, did you? Please post the entire thing.

            The difficult we do right away... ...the impossible takes slightly longer.

            A Offline
            A Offline
            AtaChris
            wrote on last edited by
            #5

            Hello, please see below for the whole message: Time Source Message 23.04.2024 09:18:14 ChartData Self referencing loop detected with type 'SampleIndi.SampleIndicator'. Path 'MyTradeManager._tradeManager.TradingVolumeInfo.Drawer.Data.Panels[0].Indicators.$values'.

            1 Reply Last reply
            0
            • A AtaChris

              With the following code:

              public SampleIndicator ()
              {
              _tradeManager = new(TradingManager ); <- Here the problem occurs !!!
              }

              I want to "inject" TradingManager into my own object _tradeManager which already works as expectet. The problem is the errors message I get from the logging window of the app that uses my plugin dll. Unfortunaltely I do not have access to the source code of that app, only to my dll.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              That's not how you do dependency injection. Your Indicator class is useless as it has no way of setting its TradingManager property. Also, the JsonIgnoreAttribute is only useful if you're serializing the Indicator class to a file. I'm leaving the Indicator out of your code.

              class MyTradingManager : ITradingManager
              {
              ... Code to implement the ITradingManager interface ...
              }

              internal class SampleIndicator : ExtendedIndicator
              {
              private ITradingManager _tradingManager;

                public SampleIndicator(ITradingManager tradingManager)
                {
                     \_tradingManager = tradingManager;
                }
              
                ... Code that uses the ITradingManager implementation ...
              

              }

              Note, for this to work, you cannot make SampleIndicator dependent on MyTradingManager. It should take an instance of some implementation of ITradingManager instead. MyTradingManager is that implementation. Whatever code is creating instances of this stuff has to create an instance of MyTradingManager and pass that to the constructor of SampleIndicator:

              {
              ...
              ITradingManager manager = new MyTradingManager(); // Create the dependency
              SampleIndicator indicator = new SampleIndicator(manager); // Inject the dependency into SampleIndicator
              ...
              }

              Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles. Dave Kreskowiak

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups