Ok, I suspect this might be a Visual Studio thing, but there must be some reason for this. I created from the list of default items a ListBox (Right Click on project, or fol
I have just had and resolved this exact thing..
It happened at some point during or after I duplicated a form, in a WinForms program, then renamed it to blah_Copy.
The main cs file and the designer cs file, are both partial classes. So if a method is defined in both and it has the same name and parameters (or same name and same no paramters) , / same signature then it will clash.
In my case they both, both Initialize() { .. } definitions, had identical bodies so I easily just removed one.
Also let's say the method is Initialize() (it was in my case). If you go to call itself, then hit F12 it will go to one of((or perhaps even at least one), of the definitions.
My problem was the project that was giving me the ambiguous call had a reference to its own dll. This was causing the method to be referenced from the dll as well as in the actual project. Once i removed the dll from the references the ambiguous call error went away.
Both classes are partial, meaning they share each others non private fields & methods.
Your ListBox1
does have two InitializeComponent
(shared) methods. Changing the namespace of either ListBox1
will resolve this error.
I had the same problem after changing a bunch of files at once, here's how I fixed it:
.. and that's it! Visual Studio can be weird sometimes..
I think InitializeComponent() is declared in two different locations in the same class.
Try to find both class definitions using CTR+F and then resolve solve the ambiguity.
Can happen if you are not alert and careful about how you use Resharper.
This happened to me when a I allowed Resharper to auto-import references while I was coding.
So having mistyped initially, then edited the code I was working on, I did not check what it had imported. After running into the same issue, I realised that there was a self-reference in the same library. So there were double implementations of the method in question.