I am experiencing an error that I am unable to resolve for some time now. I was wondering if someone can help identify the cause of this error? I am completely new to asp / asax. After some research, I think that the error I am getting is due to the web application trying to use outdated code. I was thinking to rebuild the c# file using Visual Studio and/or the entire project. However, I am completely new to C# and asp, and was wondering can give me some suggestions if this may fix the problem and/or if there is an possible alternate solution.
Error message
Parser Error Message: Could not load type 'Inventory1.Global'.
Source Error: <%@ Application Codebehind="Global.asax.cs" Inherits="Inventory1.Global" %>
Entire Global.asax contents:
<%@ Application Codebehind="Global.asax.cs" Inherits="Inventory1.Global" %>
It can't find the necessary file in dll assembly. Rebuild the project, Rebuild the solution and then try it again.
means that a type could not be loaded. (In this case, "type" refers to
Inventory1.Global
). Types are located in compiled DLLs. So, either the DLL isn't available, is out of date, or doesn't contain apublic
type with the given name.Some possible causes are:
Note: avoid names like
Inventory1
. They imply that there is anInventory2
,Inventory3
, etc., which is bad practice as they're abmiguous and not very descriptive. Also,Global
is pretty vague, and may introduce confusion with the global namespace.Inventory1
, notINVENTORY1
.)public
.If I had to guess, I'd put my money on a compilation error. Unlike PHP and other interpreted languages, C# have to be successfully compiled before they can be used.
Try replacing CodeBehind with CodeFile
After scouring around for what could have caused this I found a few things that I needed to do to get my project running...
(Note: You may not need to do all of these - it is a case-by-case thing)
If you did any changes from IIS Express to Local IIS you may need to change the build configuration from
bin/debug
tobin
. (Right click on solution >> Properties >> Build >> Output)If you have a URL rewrite then you will need to install URL rewrite on your Local IIS.
Navigate to your
applicationhosts.config
file (usually it's some place likeC:\Users\username\Documents\IISExpress\config
) and rename the file toapplicationhostsOLD.config
.Clean and rebuild your project. You may need to go manually empty out the bin.
Now you should be good to go.
This happened with me on my local machine. The issue was incorrect IISExpres config. If you are getting this issue on your local environment (Visual Studio debug runs), check the IIS Express config file. Make sure your local site/application path is pointing to the correct location.
The configuration file is called
applicationhost.config
. It's stored here: My Documents > IIS Express > config . Usually (not always) one of these paths will work:I just got this error today. It turns out that it was because I reverted by mistake the project file to an older version that didn't include the page anymore.