Stack Trace:
System.ArgumentException: Delegate to an instance method cannot have null 'this'.
at System.MulticastDelegate.ThrowNullThisInDelegateToInstance()
at APP.MainForm.mainFunctions.<>c__DisplayClass16_1.<startChecking>b__1(ValueTuple`2 config)
at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at APP.MainForm.mainFunctions.<>c__DisplayClass16_0.<startChecking>b__0()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
Related Code:
if(selectedConfigNames != "NULL") {
string[] selectedConfigNamesSplit = selectedConfigNames.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
if(selectedConfigNames.Count() > 0) {
List<(string, string)> selectedConfigsPre = configs.ToArray().Where(config => selectedConfigNamesSplit.Any((config.Item1).Equals)).ToList();
}
}
As you can see, a strange error is occuring, im not fully sure why its occuring either so I dont have much that I can really say here :/
Any help debugging would be great!
EDIT
It's definitely to do with a NullReferenceException but the strange thing is, it is almost impossible for my code to return a null. Unless WebClient.DownloadData() (.GetString'd) can somehow return a null.
Heres my current code:
string[] selectedConfigNamesSplit = selectedConfigNames.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries);
if (selectedConfigNamesSplit.Count() > 0) {
configs.ToArray().Where(config => selectedConfigNamesSplit.Any(split => ((config.Item1).Equals(split))).ToList()
}
And here's the updated stack trace:
System.NullReferenceException: Object reference not set to an instance of an object.
at APP.MainForm.mainFunctions.<>c__DisplayClass16_2.<startChecking>b__2(String split)
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
at APP.MainForm.mainFunctions.<>c__DisplayClass16_1.<startChecking>b__1(ValueTuple`2 config)
at System.Linq.Enumerable.WhereArrayIterator`1.MoveNext()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at APP.MainForm.mainFunctions.<>c__DisplayClass16_0.<startChecking>b__0()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
So from what I can see, "split" is returning null, but how is that? As you can see in the first code block, it does .Count() checks and has a setting on .Split() to remove empty entries?
It can of course be resolved by doing:
configs.ToArray().Where(config => selectedConfigNamesSplit.Any(split => (split != null ? (config.Item1).Equals(split) : false))).ToList()
I can confirm this doesnt even work, so what the hell is causing this "NullReferenceException"?
But i'd prefer to be able to know where this error is actually occurring.