Discussion:
"ambiguous match found" error
(too old to reply)
Anthony Ruggeri
2004-01-30 16:34:52 UTC
Permalink
I've heard a little bit about the "ambiguous match found" problem with
VB.Net custom controls. We suddenly started getting this error yesterday.
We are running ASP.NET 1.1 and using Visual Studio 2003.

Has anyone else seen this error and (better yet) a solution? I heard that
it was fixed in 1.1 but it obviously is not.
Christian Falch
2004-01-30 18:23:00 UTC
Permalink
Hi,
Post by Anthony Ruggeri
I've heard a little bit about the "ambiguous match found" problem with
VB.Net custom controls. We suddenly started getting this error yesterday.
We are running ASP.NET 1.1 and using Visual Studio 2003.
Has anyone else seen this error and (better yet) a solution? I heard that
it was fixed in 1.1 but it obviously is not.
I saw it yesterday, and fixed it yesterday as well.

The reason behind why I experienced the error message can be described
with the following scenario:

I've got two classes; MyBaseClass and MyDerivedBaseClass. Both has a
property called ParentBaseControl which is returns an instance of
MyBaseClass in MyBaseClass controls, and is overridden by the keyword
"new" in the class MyDerivedBaseClass:

public class MyBaseClass
{
public MyBaseClass ParentBaseControl...
}

public class MyDerivedBaseClass: MyBaseClass
{
public new MyDervivedBaseClass ParentBaseControl...
}

When using reflection to set the property ParentBaseControl, I get the
error message you described, since reflection can't decide which of the
two properties to use (which is correct, since both are accessible in
the derived class: the parent class' property can be set with
base.ParentBaseControl = value).

The solution was simply to give the property a different name in the
derived class.

Hope this helps!

--
Chris
Anthony Ruggeri
2004-01-30 20:11:30 UTC
Permalink
Unfortunately changing the name of the property is not really an option,
since the idea is that derived classes will expose the same interface as is
found in the base class.

Plus we are using VB.NET, not C#.
Post by Christian Falch
Hi,
Post by Anthony Ruggeri
I've heard a little bit about the "ambiguous match found" problem with
VB.Net custom controls. We suddenly started getting this error yesterday.
We are running ASP.NET 1.1 and using Visual Studio 2003.
Has anyone else seen this error and (better yet) a solution? I heard that
it was fixed in 1.1 but it obviously is not.
I saw it yesterday, and fixed it yesterday as well.
The reason behind why I experienced the error message can be described
I've got two classes; MyBaseClass and MyDerivedBaseClass. Both has a
property called ParentBaseControl which is returns an instance of
MyBaseClass in MyBaseClass controls, and is overridden by the keyword
public class MyBaseClass
{
public MyBaseClass ParentBaseControl...
}
public class MyDerivedBaseClass: MyBaseClass
{
public new MyDervivedBaseClass ParentBaseControl...
}
When using reflection to set the property ParentBaseControl, I get the
error message you described, since reflection can't decide which of the
two properties to use (which is correct, since both are accessible in
the derived class: the parent class' property can be set with
base.ParentBaseControl = value).
The solution was simply to give the property a different name in the
derived class.
Hope this helps!
--
Chris
Christian Falch
2004-01-30 21:33:32 UTC
Permalink
Hi,
Post by Anthony Ruggeri
Unfortunately changing the name of the property is not really an option,
since the idea is that derived classes will expose the same interface as is
found in the base class.
So, was my suggestion the cause of the error?
Post by Anthony Ruggeri
Plus we are using VB.NET, not C#.
Yes, but since they're using the same backend, the concept is really
just the same.

--
Chris

Loading...