I had an unpleasant time yesterday afternoon re-stabilising an ASP.NET 2.0 application after it went berserk. I don’t do that much coding in ASP.NET these days, but when I do, I seem to run into lots of problems.A fellow developer on the same project wasn’t very helpful or sympathetic – he sat there and informed everyone in a loud voice that he’d just come off another project where he’d built a much larger ASP.NET app without any problems at all. Yes, thanks for the support!
I had several problems layered on top of one another, including those strange issues where Visual Studio 2005 seems to get into a complete mess somehow with assembly references.I also saw evidence of Visual Studio putting incorrect duplicate file references into the project file.Killing every bin and obj folder and deleting the entire contents of the Temporary ASP.NET Files folder helped no end.However, I had one problem that I couldn’t clear for ages. Certain .aspx pages constantly reported errors associated with their @Page directives. One page, in particular, constantly reported this error (even after I had re-built the page from scratch), and others intermittently reported the same error! The error message stated that:
“There is no build provider registered for the extension ”. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value ‘Web’ or ‘All’.”
Why on earth would I need to register a build provider for non-existent file extensions? The problem seemed also to manifest itself in an inability to find a master page unless I provided a fully qualified path name. Another strange thing was that sometimes a different error would be reported by Visual Studio saying that part of the path to the web application directory could not be found. Needless to say the path was correct and present. The problem survived cleaning down the project and rebooting the system.
I tried everything I could think of to solve the issue. Nothing worked until, by trial and error, I hit on a solution. In Web.Config, I added the following buildProviders extension entry to the compilation element:
<compilation debug=”true”>
<buildProviders>
<add extension=”*” type=”System.Web.Compilation.PageBuildProvider”/>
</buildProviders>
</compilation>
Success! The problem disappeared. I then had the presence of mind to IMMEDIATELY go back and comment out the buildProvider entry.The problem did not come back! Whatever happened when I added the build provider seems to have solved the underlying issue.
I can’t explain the cause, but I can see a few reports of the same delinquent behaviour when I Google. Hopefully this will be of help to someone out there. I really do hope Microsoft has put some effort into stabilising Visual Studio 2008 rather than just concentrating on adding features.
Also, before someone asks, yes, I do have Visual Studio 2005 SP1 installed, and yes, I am using a Web Application project rather than a Web Site project.