15 January 2007
ASP.NET 2.0, pre-compiled site and Ambiguous match found
If you ran into "Ambiguous match found" after you deploy a pre-compiled site, you might've ran into a case-insenstive variable issue and in my case, it's in one of my user control. Most of the pages in my application runs fine, until it gets to the page that load this user control, it blows up.
I searched all over the web and I couldn't find a solution to this and so I decided to fire up
Lutz Roeder's .NET Reflector, loaded the dll that I compiled using the "web deployment project" and digged deep down into the page where the error happened.
When I scrolled all the way down to where the blue icon shows up (which means they are the variables that I declared) and I noticed I have two variables "TotalCount" and "totalCount", the exact same spelling but case is different. I checked back to my orignal source code, "TotalCount" is the ID of a hyperlink control in my .aspx page and "totalCount" is a private variable in my codeBebind .cs file. Could this be the problem "Ambiguous"?
So I quickly did a global replace of "totalCount" to "totalCountForAll" in my .cs file and recompiled the "web deployment project', re-loaded the application, voilla, error is gone!
Funny thing though, this didn't happen if I unchecked the option "allow this pre-compiled site to be updatedable" in my web development project "compilation" property. It only happens when I checked it.
Sometimes, I wish I can get back my 22 hours of nothing, okay, substract out the "too tired, i need 4 hour nap" hours!! Now it's time to re-test my entire site, in case any other pages might have the same issue!!! (i don't understand why the compiler didn't catch it during compilation, what's up microsoft???)
Hope this helps out any of you.