- ago
Hi,

since build 28 or 29 I have an runtime error when creating a new instance of BarHistory in a C# project (Visual Studio):
CODE:
BarHistory bh = new BarHistory("AAPL", HistoryScale.Daily);



In C# Code Editor it's working fine.

Do you have any idea?

Thanks!
0
780
Solved
20 Replies

Reply

Bookmark

Sort
- ago
#1
Delete referenced assemblies in your VS project and add them again.
0
- ago
#2
I have done that but I get the same error.

And sorry, it's not an compile error, it's an runtime error! In VS it compiles successfully.

When I use the compiled strategy in WL, I get the compile error:
QUOTE:
Backtest Error: Could not compile the Strategy.




0
Glitch8
 ( 12.08% )
- ago
#3
We promoted the MassageColors method from IndicatorBase up to TimeSeries, to provide more flexibility controlling colors in coded strategies. Can you recompile your coded strategy library?
0
- ago
#4
It doesn't help.
0
Cone8
 ( 28.25% )
- ago
#5
Try "Clean Solution" and then "Rebuild Solution" (not just Build).
0
- ago
#6
This is what I did. But it runs into the same error.
0
Cone8
 ( 28.25% )
- ago
#7
It seems clear your solution is pointing to an outdated or incorrect build artifact.
0
- ago
#8
Even if I make a new solution (console app) from the scratch I get the error:

CODE:
using WealthLab.Core; namespace ConsoleApp1 { internal class Program { static void Main(string[] args) { BarHistory bh = new BarHistory("AAPL", Frequency.Daily); } } }


System.NullReferenceException
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=WealthLab.Core
StackTrace:
at WealthLab.Indicators.IndicatorFactory.get_MassageColors()
at WealthLab.Core.TimeSeries..ctor(List`1 dateTimes, Boolean fillNaN)
at WealthLab.Core.BarHistory.RegisterTag()
at WealthLab.Core.BarHistory..ctor(String symbol, Frequency scale)
at ConsoleApp1.Program.Main(String[] args) in ...
0
Cone8
 ( 28.25% )
- ago
#9
Okay, we're going to look into it. Stand by!
0
- ago
#10
Looks like we need a hotfix for compiled strategies affected in the current build.
0
- ago
#11
Many thanks for fixing the problem. It works like expected again!
1
- ago
#12
Correction: In VS the Problem still exists (error when creating instances of BarHistory). In the Frontend it's solved.
0
- ago
#13
We made sure it's working in VS. Whatever said in posts #5 and #1 still applies.
0
- ago
#14
Update:

If I create a new C# strategy in WL and debug it in VS (WL as attached process), it works without error.

If I use the same line
CODE:
BarHistory bh = new BarHistory("AAPL", HistoryScale.Daily);

in an console app (I use this for thesting purposes to speed up the debugging process), it fails with the error in Post #1

This behavior did not exist in previous releases!
0
Glitch8
 ( 12.08% )
- ago
#15
Using our libraries in console apps or external applications isn't supported. Still, it looks like your console app is probably referencing an outdated copy of the library.
0
Best Answer
- ago
#16
Ok, as long as I can debug, no problem for me
0
- ago
#17
Just installed Win11. All is working fine again!
0
- ago
#18
I am experiencing the same issue. It is preventing all my unit tests from running.

I am already at Win11. I implemented all latest updates.
I tried comments #1 and #5.
I tried being explicit in the project file to the new version of the libraries.
I tried searching for and deleting all old versions of the WealthLab dlls.
I am going to try branching next.

Please let me know other suggestions. Thanks Phil
0
- ago
#19
This is really interesting, my unit test under Win10 do what they should. It's just this one runtime error. Ok, I let you know when I have found the reason (although i think that's a Microsoft issue, this would'nt be the first time)
1
- ago
#20
This remains an issue for me. As you say it might be a visual studio issue rather than a wealthlab issue.

I created a new project and implemented a simple unit test:

CODE:
using WealthLab.Core; namespace TestProject { [TestClass] public class UnitTest1 { [TestMethod] public void TestMethod1() { var bars = new BarHistory("AAPL", HistoryScale.Daily); var result = bars.Count > 0; Assert.IsTrue(result); } } }


With the project dependency assembly set to my previous version (build 26) it works.
However if I change to the latest version (build 30) if fails with the error message you report.
It still suggests to me that the BarHistory constructor needs something initialized in TimeSeries Indicators that I did not need previously.

Thank for the help
0

Reply

Bookmark

Sort