In my .Net 2.0 Asp.net WebForms app, I have my Global.asax containing the following code:
<%@ Application CodeBehind="Global.asax.cs" Inherits="MyNamespace.Global" Language="C#" %>
However when I build I get an error stating-
Could not load type 'MyNamespace.Global'.
This seems to be because the MyNamespace namespace (defined in the code behind file Global.asax.cs) is not seen by the compiler in the Global.asax file (does not show in R# intellisence..). This turned out to be a very hard nut to crack... any help will be appreciated!
Note: The Global.asax and the Global.asax.cs are located in the same folder.
Note2: When compiling from the vs prompt with csc it compiles o.k.
In my case, I had added Global.asax to a WCF project to experiment with it, but decided to remove it. I removed it from Solution Explorer, but because it was still in the folder, the pipeline was still finding it and causing this error.
I removed the Global.ASAX and GLobal.asax.cs from the filesystem and that did resolve the error.
Here's another one for the books. It appears that this happens when you launch more than one web application from the same port number.
Basically, I have a couple of branches that I work off, I have a main branch and a staging branch and a release branch. When I switched branch to the staging branch I noticed that it was using the same port address configuration so I opted to change that. I then received another warning that this reservation conflicts with another configured application. The IIS Express server is sensitive about that and for whatever reason it bricks the configuration.
By simply picking a third unaffected port this problem went away because it then maps the port to a new directory mapping (my branches are located differently on disk). I noticed this because I tried to change the type name pointed to by
Global.asax
but the type name was unchanged even after restarting the server, so clearly, the code I was changing wasn't reflected by the IIS Express deployment.So, before you lose too much sleep over this, try changing the IIS port number that is currently used to run the web project.
In my situation it was related to Web Site/Web Application type of the project. We recently moved to MVC and had to change it to Web Application.
So, the solution was simple: select your web-site in Solution Explorer and remove it from the solution, then right click on the solution and select Add -> Existing Project (not Web Site), recompile the web-site.
Works Fine For Me IN VS 2015.Now I can Use Global event. My
Global.asax
file has this LineAnd I make class file
Global.asax.cs
that is inAppCode
folder that look likeI hope this will help
I experienced this problem when I accidentally set "Chrome" to be the default browser for debugging. When I set it back to "IE" the problem disappeared. I am not sure why...
EDIT: I was about to delete this answer, because I wasn't sure about it, but then I had the problem again. I switched to browsing with Chrome, then back again to IE and it stopped! What gives!?
I had converted my solution from VS2003 to VS2010 and had had problems converting the web application project.
I experienced the exact same problem and none of the answers worked for me.
What worked for me was:
it would seem that the problems I had during the conversion had removed the web application project from the build for some reason.
Hopefully this answer helps anyone else that has the same problem...