Self referencing loop detected for property with type ...
-
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 ?
-
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 ?
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.
-
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 ?
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
-
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
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.
-
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.
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'.
-
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.
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