Hi,
I'm with the following error
Error 1 The call is ambiguous between the following methods or properties: 'EmpApp.Form1.InitializeComponent()' and 'EmpApp.Form1.InitializeComponent()'
for these codes in C#. Any idea?
using ...
namespace EmpApp
{
public class Form1 : Form
{
Label lb_user_id;
...
public Form1()
{
InitializeComponent();
}
void InitializeComponent()
{
this.lb_user_id = new System.Windows.Forms.Label();
...
Form1.Designer.cs will hold the design related info with initialisation method ( InitializeComponent() )
however it will work only when your class has "partial" attribute (means partial class)
here you have removed the partial keyword and didn't delete the Form1.designer.cs file so it got confused as Form1.Designer.cs has one more method InitializeComponent()
You should do Now:
remove initializecomponent() from your code (not in Form1.Designer.cs)
and mark the class as partial (the way it was when you have created it)
"Marking as Answer" on right answers helps others
RkChaudary
blog
wmec
Contributor
6228 Points
3226 Posts
The call is ambiguous between the following methods or properties
Feb 16, 2009 07:20 AM|LINK
Hi,
I'm with the following error
Error 1 The call is ambiguous between the following methods or properties: 'EmpApp.Form1.InitializeComponent()' and 'EmpApp.Form1.InitializeComponent()'
for these codes in C#. Any idea?
using ...
namespace EmpApp
{
public class Form1 : Form
{
Label lb_user_id;
...
public Form1()
{
InitializeComponent();
}
void InitializeComponent()
{
this.lb_user_id = new System.Windows.Forms.Label();
...
HuaMin Chen
rkchaudary
Contributor
2524 Points
545 Posts
Re: The call is ambiguous between the following methods or properties
Feb 16, 2009 07:46 AM|LINK
HI Chen,
please post entire code / EmpApp.Form1 code,
there is an ambiguity in the method name as the clr is not able to identify which method is be called.
RkChaudary
blog
wmec
Contributor
6228 Points
3226 Posts
Re: The call is ambiguous between the following methods or properties
Feb 16, 2009 08:06 AM|LINK
Thanks. The issue is due to the existence of this file (it's defaulted to be there within the solution unless we delete it)
Form1.Designer.cs
What's this for?
HuaMin Chen
rkchaudary
Contributor
2524 Points
545 Posts
Re: The call is ambiguous between the following methods or properties
Feb 16, 2009 08:32 AM|LINK
Hi Chen,
Form1.Designer.cs will hold the design related info with initialisation method ( InitializeComponent() )
however it will work only when your class has "partial" attribute (means partial class)
here you have removed the partial keyword and didn't delete the Form1.designer.cs file so it got confused as Form1.Designer.cs has one more method InitializeComponent()
You should do Now:
remove initializecomponent() from your code (not in Form1.Designer.cs)
and mark the class as partial (the way it was when you have created it)
RkChaudary
blog