I am writing a C# program using Topshelf framework to make it windows service. The app basically search for data in .csv file and uploads them to website, it works perfectly fine and it does what it is supposed to do whet it is initialized in visual studio 2022, but when i build the app and install it as windows service, I get this error message in the Log:
2024-04-23 13:36:33.704 +02:00 [ERR] Error executing scheduled task: Object reference not set to an instance of an object. System.NullReferenceException: Object reference not set to an instance of an object. at ExchangeRateUpdater.HasValidDateRange(Currency currency) in C:Usersname.surnamesourcereposAutorestartProgram.cs:line 138 at System.Linq.Utilities.<>c__DisplayClass1_01.b__0(TSource x) at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.ToArray() at System.Linq.Buffer1..ctor(IEnumerable1 source) at System.Linq.OrderedEnumerable1.ToArray(Int32 minIdx, Int32 maxIdx) at ExchangeRateUpdater.ExecuteScheduledTask(String accessToken) in C:Usersname.surnamesourcereposAutorestartProgram.cs:line 79
Whole code on github
Code snippets that the error is referring to
I would like to mention that I am new to programming and this is my first bigger project, so please be merciful 😀
Thank you all in advance.
I have tried many thing, completely change the code, did multiple versions of the program, but it either were not working at all, or ended up with this error.
user24633545 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.