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.<CombinePredicates>b__0(TSource x) at System.Linq.Enumerable.WhereSelectEnumerableIterator
2.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator1.ToArray() at System.Linq.Buffer
1..ctor(IEnumerable1 source) at System.Linq.OrderedEnumerable
1.ToArray(Int32 minIdx, Int32 maxIdx)
at ExchangeRateUpdater.ExecuteScheduledTask(String accessToken) in C:Usersname.surnamesourcereposAutorestartProgram.cs:line 79
Code snippets that the error is referring to are here
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.
user24604742 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.