15

I can't seem to figure out what I am doing wrong here. I publish my website to my server and when I try to run it I get the following exception:

Could not load the assembly 'App_Web_kh7-x3ka'. Make sure that it is compiled before accessing the page.

Has anyone else ever encountered this?

Himanshu
  • 31,810
  • 31
  • 111
  • 133
Collin Estes
  • 5,577
  • 7
  • 51
  • 71

4 Answers4

33

This can also happen when you've taken a pre-compiled aspx page and edited it as if uncompiled, such as copying it from the Live server and overwriting your dev/working version.

On the first line of your aspx page within the <%@Page /> tag you'll probably see an attribute like:

inherits="yourPageClass, App_Web_kh7-x3ka".

Delete the "App_Web_XXXX" part and add the CodeFile attribute pointing to your code behind file:

CodeFile="yourPageFile.aspx.cs"

The <%@Page /> tag should now look similar to when you create a new page from scratch.

When your Asp.Net pages are precompiled for release to the production server, references to the code behind are replaced with references to the compiled DLLs which have the App_Web_XXXX name.

ChrisAnnODell
  • 1,341
  • 15
  • 24
2

A quick google for "Make sure that it is compiled before accessing the page."

led me to the following

http://www.velocityreviews.com/forums/t301533-could-not-load-assembly-make-sure-that-it-is-compiled-before-accessing-the-page.html

And the problem might be as described that the application pool / website is not set to the correct version of .NET

The following question has another solution as the last reply http://forums.asp.net/t/1131537.aspx

From the looks up it it would seem your webserver is not properly configured, or that you are refering to a nonexistant/old dll

thmsn
  • 1,976
  • 1
  • 18
  • 25
0

We recently had this issue materialise overnight for one of our precompiled sites. Turns out our server's anti-virus software was silently quarantining one of the compiled DLL files. (apparently my code resembled an update hijacker... charming)

Slightly off-the-wall cause for this problem, but hopefully it helps someone else in future.

Red Taz
  • 4,159
  • 4
  • 38
  • 60
0

If you are using BitBucket Source Tree (e.g. with Azure), Soruce Tree by default don't upload .DLL files. You need to go -> Source Tree>Tools>Options>Git>Global Ignore List [Edit File] Remove *.Dll line and Save file.

Rebuild your project (you don't need to), Commit code, Push code!

Your site should start working...

Mubi Ali
  • 83
  • 1
  • 7