The nasty 'Ambiguous match found' error in ASP.NET 2.0

Discussion in 'ASP .Net Web Controls' started by Svetoslav Vasilev, Apr 26, 2006.

  1. Hi, I am probably not the first, neither the last one to come along a problem
    in ASP.NET 2.0 applications resulting in an 'Ambiguous match found' error
    during parsing of pages/user controls.
    To me however the problem worked somehow weired since it appeared after
    converting one ASP.NET 1.0 project to ASP.NET 2.0. You might exclamate that
    it explains everything and shouldn't read this comment further, but let me
    make this a bit more intriguating - the conversion was done with the Web
    project support extension for VS 2005. This means that there is no need to
    stick to the new web site model in ASP.NET 2.0 - it is a 1 to 1 match with
    what it used to be in VS 2003, eg. no partial classes, no ASP.NET folders, no
    So, lets cut to the chase. The web app i have is constituted mainly of user
    controls that are loaded dynamically in another user control, that on its own
    is loaded in a page. It is a proven architecture that's been running for the
    past 2 years. However, the new ASP.NET 2.0 runtime proved it wrong. The
    bottomline is simple - there is a user control A that dynamically loads
    another user control B. The user control A contains a member variable of type
    control C, named c. The user control B has an instance of the control C,
    which is defined as a custom tag in the .ascx file. The ID of the element, as
    well as the name of the member variable of type control C, defined in control
    B, is c as well.
    So when control A loads control B, the exception AmbiguousMatchException is
    thrown. Astonishing, since in ASP.NET 1.0 it works just fine!
    I had to use the WinDbg in order to track where it actually happened since
    I've got way to little info from the exception itself. It appeared that the
    problem lies in the fact that the member variables of type control C in both
    parent controls A and B are named equally. The exception is thrown inside the
    Syste.RuntimeType.GetField() method when trying to create instance of control
    C in control B.
    To me it appears that the ASP.NET 2.0 runtime does not take into
    consideration the access modifier of the member variable at all(they are
    protected). Logically there should be nothing in common between those 2
    variables dispite the same name, and this is the case in ASP.NET 1.0. They
    are basically located in separate instances of different user controls, which
    means totally isolated from each other. The only relation of those controls
    is that one contains the other through aggregation. It is as if the ASP.NET
    2.0 runtime makes this relation appear as inheritance during instantiation.
    The workaround that first comes into mind of course is to rename the member
    variable of type C in control B, which is exactly what i did. But this is a
    quick fix. I cannot imagine how many developers have to suffer and do the
    same thing, just because the ASP.NET runtime suddenly started behaving
    If this issue is acknoledged as a bug, I hope that the ASP.NET team will
    look seriously in it so that it can be soon solved, and web developers can
    continue to focus on more important business logic matters, rahter than
    renaming variables in order to make their apps run again in the new
    If not, let me know where I make mistake.
    Best regards.
    Svetoslav Vasilev, Apr 26, 2006
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Denon
    Yuke Liew
    Jan 2, 2004
  2. Ben

    Ambiguous match found.

    Ben, Apr 27, 2005, in forum: ASP .Net
    Mar 23, 2010
  3. =?Utf-8?B?QWxleGFuZHJl?=

    Error: Ambiguous match found.

    =?Utf-8?B?QWxleGFuZHJl?=, Apr 23, 2006, in forum: ASP .Net
    Oct 1, 2009
  4. Francois
    Hans Kesting
    May 22, 2007
  5. aparna

    Ambiguous match found

    aparna, Mar 25, 2008, in forum: ASP .Net
    Mar 26, 2008
  6. Craig Jewiss via .NET 247

    "Error Creating Control" - "Ambiguous match found"

    Craig Jewiss via .NET 247, Apr 26, 2004, in forum: ASP .Net Building Controls
    Craig Jewiss via .NET 247
    Apr 26, 2004
  7. Anthony Ruggeri

    "ambiguous match found" error

    Anthony Ruggeri, Jan 30, 2004, in forum: ASP .Net Web Controls
    Anthony Ruggeri
    Jan 30, 2004
  8. Victor Irzak

    Please HELP!!! parser error: ambiguous match found.

    Victor Irzak, Apr 19, 2004, in forum: ASP .Net Web Controls
    Victor Irzak
    Apr 19, 2004