'System.ArgumentNullException: 'Value cannot be null. (Parameter 'source')' [duplicate]

This is an old project of mine. i haven't opened it for some time. As far as i remember it was working perfectly fine. but today when i opend it it stopped working. i haven't change a single line of code. it just stopped working(it builds just fine but dont start after). After a full night of frustration i found the reason of why its not starting but couldn't imagine or find any possible solution, cause it was eorking perfectly fine but suddenly it decided to stop working. Please help :)

i have no idea why this exception is showing now. the code was running perfectly before

i swear i haven't changed a single line of code. not even a coma.



Solution 1:[1]

It's because you have called PopulateGridViewEmployee with an empty searchKey which is an Optional Argument set to Null.

Hence you're getting System.ArgumentNullException

To fix it change the optional argument to have an empty string:

PopulateGridViewEmployee(string searchKey = "")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeremy Thompson