Ambiguous match found

Looks like I've been away a few months. Sorry 'bout that. I've had stuff to write about but not enough time to set aside to do so, which is a little ironic; one of the main reasons I created this blog was so I could take 5 minutes and jot down stuff I find out while developing, largely in case it helps others, not so I could write my usual verbose 5000 word essays (which is what my AspAlliance site is for!).

So, on that note, I wanted to share how I solved a goofy error that made no sense. I was upgrading a good-sized web application from .NET 1.1/Visual Studio 2003 to .NET 2.0/Visual Studio 2005 using Scott Guthrie's well-written instructions and the Web Application Projects add-in. Going through VS2005's automatic conversion and building it was pretty painless when I followed Scott's instructions; one wrinkle I ran into is that it forgot about the three web projects, so I had to add those manually using "Add Existing Project" after I converted the others.

But it built and I went through the app and everything was fine. I didn't do the "Convert to Web Application" command on the whole project, preferring to keep a closer eye on what it changed, and touch it up after. So I started doing it folder by folder per Step 8 inScott's instructions, and it seemed to work great, until I got to one particular page and got this error.

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Ambiguous match found.

Source Error:

Line 1:  <%@ Control language="c#" Inherits="MyApp.Namespace.MyCoolControl" CodeBehind="
MyCoolControl.ascx.cs" AutoEventWireup="false" %>
Line 2:  <%@ Import Namespace="
MyApp.OtherNamespace" %>
Line 3:  <div class="openingParagraph">

Source File: /MyApp/Namespace/
MyCoolControl.ascx    Line: 1

So it says Line 1, Line 1 is highlighted, and yet, the only reference in line 1 is a fully-qualified one. To be safe, I pulled all my custom assemblies into the invaluable .NET Reflector and double-checked, and there was only one instance of that class name anywhere.

I tried what I normally try when I get weird ASP.NET errors I shouldn't be getting, a process many of you are probably too familiar with if you've worked with ASP.NET very long. I restarted IIS, deleted and recreated the application in IIS Manager, deleted the Temporary ASP.NET Files directory for MyApp (after closing Visual Studio), restarted Visual Studio and rebuilt the project, etc. None of these helped this time.

Scott's instructions mentioned this error in some cases, notably the IE WebControls, but the solution has been to specify the full namespace, not just the class name, so that didn't help me. Other Google search results were similarly unhelpful, until I found the blog of a guy named Eran Sandler who talked about his "Ambiguous match found" error and how he solved it--two protected fields with names that differed only in case, apparently confusing reflection.

Sure enough, my code had the same problem--I had myRepeaterControl (name changed to protect the innocent, of course), and MyRepeaterControl in my code-behind. The latter wasn't used and was probably left in mistakenly; I removed it, it still built fine, and the control worked great.

Thanks, Eran!


  • Hi There Peter.

    I'm glad that my post helped you solve the problem :-)

    It's always nice to see that something I write about in the blog eventually help real people in real situations.

  • Hi, I had the same problem. It turned out to be a different resolution: The web site was configured for .NET 2.0 instead of .NET 1.1 (as the case for this old project). Changed it in IIS Settings (ASP.NET tab) and fixed. May help someone else.

  • Thank you so much, this definitely helped end my frustration with this problem! Only wish I could have found it sooner! :)

  • Sure saved me many hours. Thanks!

  • This really helped thanku.

  • Thanks! Saved us lots of time, too. One more thing of note: it doesn't seem to matter that the two similarly named fields both be protected. I changed one of mine to private -- it no longer needed the protected scope anyway -- but that did'nt help. Only by giving them different names did the page work.

  • Thanks Peter for clarifying this head-scratcher. It really saved me a bunch of time.

  • Fabulous - you've saved my bacon.

  • Thank's Peter... this one stumped me till I just ran across your blog.

  • Thankyou. That solved my issue too, I renamed my private variables, redeployed and it worked.

  • I run into the similar problem. I found the solution reading you blog. I post my owner intro. Thank you !

  • thanks, i have the same problem.

  • Thank's Peter, I'd been scratching my head for ages with this problem until I found this blog. 30 seconds later the issue was fixed. Just in time too, the software is being released to a customer tomorrow.

  • how did you guys find the similarly named controls?

  • This solved my problem, thanks!

  • Changing the IIS settings helped, thanks a bunch :) We have two environments going one on 2.0 and one on 1.1 and someone must have switched the 1.1 to 2.0 by accident, this saved me hours.

  • Thanks a lot, it was great that i found the solution atlast through your blog. Great work.

  • MUCH appreciated!
    I thought for sure my IIS was screwed up - until I got the same error on another machine. Got smart and found your post - thanks for taking the time to put this kind of info up!

  • mdmangus:

    I don't have time to dig into it much right now, but it makes sense that you're solving the same problem/cause a different way. I got the error when dynamic compilation (on MyCoolControl.ascx) ran into a naming conflict, and you skipped dynamic compilation by compiling it all ahead of time. Offhand though, I'm not sure why you wouldn't get the error during build/publish (which I believe does the tasks done during dynamic compilation, just ahead of time).


  • I checked the all the naming of control placed on the web page.I found one protected asp:textbox control has similar name(Role) with the private string role.I changed the Role to txtRole.And a dynamic asp:label created twice in my page.I removed one of the dynamically created label control.It fixed my problem

    Thanks a lot for the information provided on this blog.

  • I had this problem when uploading a .net v1.1 app to v2.0 hosting. I set the hosting to v1.1 and the problem was solved.

  • Thanks. It helped me to solve my problem

  • Brilliant, saved me a lot of time. Thanks.

  • I found this error when I have my webservice installed in ver 1.1 in a different pool and my application in ver 2.0 in a different pool

  • I used the "Allow this precompiled site to be updated" advice above and this fixed the problem for me. This is a great relief because the page I was having the issue with has some 50 controls on it. I could compile and run this page locally without error, but when deployed I would get the runtime error "Ambigous Match Found". This kind of cr@p drives me nuts, so glad there was an easy fix!

  • Thanks for this post, saved me loads of time!

  • Thanks Martin Bell! VS found it easily with the 'Convert to web application'.

  • I tried the following trick and it works. Thanks.

    re: Ambiguous match found

    Hi, I had the same problem. It turned out to be a different resolution: The web site was configured for .NET 2.0 instead of .NET 1.1 (as the case for this old project). Changed it in IIS Settings (ASP.NET tab) and fixed. May help someone else.

  • Thanks for the solution and also thanks for the Hans Kesting tip.

  • Thanks a lot Peter. Your post helped solve my problem very quickly.
    I also liked the following tip:
    "Thursday, October 11, 2007 4:55 AM by Hans Kesting"

  • Thank You very much Peter. You know it helped me a lot, coz I wasted lot of time in fixing this error but all gone in vain. I once again thank you.

  • Rockin! The twenty second solution to what I dreaded would have been a killer...

  • It's the problem with ASP.NET version

  • Thanks! This solved my problem as well!

  • Thank you very very much, I had the problem where a private variable had the same name as a control i.e bool btnhelp and WebControl BtnHelp and it only happened on a .net 2.0 website, 1.1 did not complain

  • Thanks very much for this info, i had a dropdownlist on a page with the name GroupList, which clashed with an object in the code behind page called groupList

  • Thx a lot Your'e a coding time saviour ;-)

  • This was a great post. Saved me heaps of time. The error itself is terrible though.

  • I had the same error. Had a hard time finding it since the name with variant case was distributed in the aspx and code behind.

    Thanks a bunch! Saved me a lot of time...

  • WOW!!! Thanks! Saved us lots of time,

    This came up as the first item in my google...
    Read it... THought Hmmmmmm....
    Went to my members drop down in the ide, and slowly scrolled down... and there it was same name just cased differently!!!! changed the one variable name and POW!! running like a champ!!!!!!!

    THANK YOU !!!!!!!!!!!!!!!!!!!

  • Thanks So Much! Maybe the error should be changed to Ambiguous Error Message Found, just to make things clear :-}

    Unfortunately Eran Sandler's blog is gone, but the duplicate name issue is also what i had.

    Thanks Again!

  • My version of the problem was that the wrong level of .net was specified for the app (2.x instead of the correct one, 1.x. It would have taken me a long time to figure that out, without the help here. Thanx.

  • Easiest way to find the case mismatches is just try "Convert to Web Application" on that particular page, .NET designer will show you the variable name! :)


  • Thanks for your kind information

  • Thank u man. Good solution .

  • Hah.. I remember doing this before, thanks for the memory.. I just did it again! DOH
    Thanks..I am such a bonehead

  • Worked for me too, thanks!

  • What worked for me was running

    aspnet_regiis -r

    in the WINDOWS\Microsoft.NET\Framework\v* folder for the appropriate version of .NET to update script maps. I did not have to change any code. My problem was evidently due to running an older version of my application that needed v1.1.4322 while v2.0.50727 was still installed (left over from a previous run with a newer version).

  • Thanks a lot, it's works great !

  • Thank you sooooo much.
    That's the bad things of copy-pasting code without even changing it at least to your style / coding standards. argghhh....

  • so sad ...the blog had been removed... Dunno how to solve it now

  • Goober:

    Sure enough, Eran Sandler's blog is gone.

    But read my post carefully--the problem is having two variables with the same name differing only by case, like myRepeaterControl and MyRepeaterControl. You solve it by removing/renaming one of them to a "more distinct" name.


  • Thanks a lot! Worked like a charm.

  • Thanks for this. In my case I'm pretty sure that the conversion tool itself generated the error. If it gave a warning i either missed or ignored it :-) I had a control on the .aspx page differing in case from the C# class. I suspect the tool added the ASP control to the designer class, then failed to match and remove it from the original C# class file, leaving two ambiguous controls. I had to binary chop the ASP to locate the offending control, but afterwards I realised that a careful reading of the class in Object browser would have found the "duplicate". Woudl have been nice if the error message had *named* the ambiguous control :-)

  • Sehr wertvolle Informationen! Empfehlen!

  • I solved the error by returning to .NET Framework 1.1 of which the aplication was written for.

  • You and Evan are kings among men!! Luckily your page was the second one I checked after having this problem!! Thanks!

  • Even thou my problem was the same the solution of it was different. In my case it was returning the infamous error because I named a column in my table (SQL Server 2005) as being "Tag". It looks like that the parser was making confusion while running my .netTiers application. I renamed it to "Description" and it worked out.

  • Thanks for this wonderful blog.. It instantly solved my problem. The problem occured whicle publishing the web site , there was an unused hidden field that was specified with the same name as of the string variable in codebeind.
    I removed the hidden variable and now its working... Thanks again...

  • Almost three years old, and yet this post continues to save people (myself included) from hours of frustrating wild goose chases. Thank you both, Peter and Eran!

  • Hey ...thanks for the post, I had the same problem after migrating an web app from 1.1 version to 2.0. After reading this blog, i checked my code and yes i found variables with same name ,but differed in case.Hope Microsoft will have a look at this issue and makes a better compiler

  • Great post! You solved my issue caused migration from .net 1.1 to .net 2 in a webapps.
    Also I had 2 variables with the same name, but different case. Now it works perfectly.
    It is a very absurd bug, I would have never solved it alone...

    Thank you

  • Bless you. You probably saved me an entire day of troubleshooting.

  • Many thanks Peter - this little gem saved me a lot of hassle :)

  • THXXX!
    now it's working again ^^

  • Thanks a lot, this helped me, i was frustrated with this problem. Thanks once again. keep up the good work.

  • You sir solved my problem.

  • Thank you so much... I know this is an older post, but this saved me more insanity than you will ever know. God Bless You, Sir.

  • Please check ur site may be mapped with wrong framework.

  • fractalnavel,

    Thanks for the updated URL! I've updated the post accordingly.


  • Hi,

    My fix was resolved by Unchecking "Allow this precompiled site to be updated" through Publish Web Site.

    Thanks a ton for the help.

  • Hi,

    I'm glad I've come across this page. It helped me figure out where the issue was because the error didn't always occur.

    For me I was inheriting an object and also defining properties with the same name.

    Thanks. You saved my day.

  • Thanks. it work like a magic on me.. thanks alot

  • Ashish,

    Thanks for the kind words! And for the note about the Visual Studio warning. It sounds like they've updated VS to detect when you're going to get this vague error before you actually get it, a decent "band aid" warning short of what I would consider a "true" fix of making the error message more helpful. What version of Visual Studio are you using?


  • Helped me solve my problem.

    It turned out I defined a drop-down list named Country on aspx. On the aspx.cs, I was busy copy/pasting and I accidentally declared it as

    protected System.Web.UI.WebControls.TextBox Country

    Once I changed it to DropDownList, error went away.

  • thanks for the soln..
    i tried to find it hard and found one protected variable that too, Form1 , with differnt case in the two files :$

  • Thanks a lot! It was one day of work to find out that it was due to 1.1 code running in 2.0 version in iis. But it was giving issue only in one page. When I changed to 1.1 it worked for me but the real issue was having two same named labels declaration with case mismatch.

  • Thanks Martin Bell. I spent an entire day correcting case-sensitive markup errors. I knew my problem was in the markup, but could not figure out what control was causing it. Your post make the most sense. That was a cool trick and it fixed my problem.

  • Bingo! Your post is almost 5 years old and is still helping people! How the heck you figured out the cause of the issue in the first-place with that completely useless error message is beyond me. This could have cost me a couple days of head-scratching, easy.
    Hat's off and thank-you!

  • Thank u, Peter. and thanks a lot to Eran.
    You guys are life saving..

  • Thanks Man

    It Save My Lot of time

  • I have the same problem but does not have such case sensitive issue as explained above. Still struggling :(

  • Thanks. This helped me in identifying the same issue I faced in my page.

  • Awesome Post!!

    Saved me a lot of searching and frustrating moments.

    Thanks a million Peter!!

  • My fix was resolved by Unchecking "Allow this precompiled site to be updated" through Publish Web Site. Uploaded code to production server and everything worked fine.

  • I've the same problem and it solved and the solution is in check your code behind and you will find a couple of Controls with the same name:

    protected Button Home;

    protected System.Web.UI.HtmlControls.HtmlAnchor home;

    you have to erase one line or comment it.

    thanks a lot.

  • Thanks we always need your help

  • I had same problem, but by following your post, i Commented all code and checked step by step and found the names of the session and global variable were same, after changing them its working now :)

  • Wow, that was exactly the problem.. Thanks a ton Peter! Really saved a lot of time :)

  • I changed


    and my form worked!

    You probably just saved me an hour of debugging!
    Thank you!

Comments have been disabled for this content.