Friday, December 17, 2010

Missing DLL causes error "file has not been pre-compiled, and cannot be requested"

My .NET 2.0 website used an old version of Telerik's RadWindow control. I replaced this with a recent version of Telerik RadControls for ASP.NET AJAX. When I tested the website on my local machine, it worked fine. When I uploaded it to the web server, though, attempting to view any page resulted in an error of the form

The file '/step1.aspx' has not been pre-compiled, and cannot be requested.

The filename step1.aspx would be replaced with the name of whatever page I was trying to view.

I eventually determined that the error message didn't mean at all what it said. What it really meant was that Telerik.Web.UI.dll was missing from the website's bin folder. The Telerik control was referenced in a master page that was used by most pages of the site, and therefore the error occurred on almost every page.

Simply adding the missing DLL to the bin folder resolved the problem. I then got to wondering why the DLL was missing in the first place. Here's the answer.

I installed Telerik RadControls for ASP.NET AJAX using the MSI installer provided by Telerik. Among other things, this installed Telerik.Web.UI.dll to C:\Program Files (x86)\Telerik\RadControls for ASP.NET AJAX Q1 2010\Bin20.

I copied Telerik.Web.UI.dll from there to a folder named Shared Assemblies in my .NET solution. I use this folder to store some third-party DLLs to which one or more of my projects make references.

In my project, I added a reference by browsing to the copy of Telerik.Web.UI.dll in my Shared Assemblies folder. Nonetheless, Visual Studio added the reference from the GAC, and did not copy the DLL to my project's bin folder. Because my project was a website, not a web application, I had no option to select "copy local" when adding the reference.

So my only recourse was to manually copy Telerik.Web.UI.dll into the bin folder and add it to source control. Now when I publish my project, the DLL is where it needs to be, and the error no longer occurs.

By the way, this is not specific to Telerik. I've noticed other people have had similar problems with other DLLs, especially ReportViewer.

No comments:

Post a Comment