Reputation: 267
I know this issue has been raised before, but the solutions available have not resolved my problem.
I have a global.asax file that I did not write, in my solution. The namespace and class from the cs file match the inheritance namespace and class.
What caused the issue was something simple: I excluded a directory from the solution, then re-included it. Since then, the error below occurs when I attempt to build my solution:
Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load type 'EnableWebApp.Global'.
Source Error:
Line 1: <%@ Application Codebehind="Global.asax.cs" Inherits="EnableWebApp.Global" Language="C#" %>
Source File: /global.asax Line: 1
I have cleaned, rebuilt, reinstalled these files, restarted the framework, and rebooted my system. Nothing has resolved it yet.
Global.asax "<%@ Application Codebehind="Global.asax.cs" Inherits="EnableWebApp.Global" Language="C#" %>"
Global.asax.cs namespace EnableWebApp { public class Global : System.Web.HttpApplication {
Upvotes: 2
Views: 9699
Reputation: 11
Another solution that worked for me consists of building project that are considered as children of the master solution. I opened the .csproj file linked with a .NET website, compiled this project and then, re-opened the master solution. The previous error disappeared.
Upvotes: 0
Reputation: 1
If you are using "Local IIS" and your compiling path is not "bin/debug" ...
It happens to me that IIS changes the physical path of the application under debug. This happens closing/reopening VS and also changing branch with GIT. So, double check that your IIS app configuration keep on be correct and in case fix it. At the end, my workaround to solve this annoying problem has been to add to my solution a simple consol project that is compiled and launched as post-build event to automatically set the correct path in IIS:
static int Main(string[] args)
{
int result = 0;
try
{
ServerManager serverManager = new ServerManager();
var myApp = serverManager.Sites["Default Web Site"].Applications["/myApp"].VirtualDirectories[0];
myApp.PhysicalPath = args[0];
serverManager.CommitChanges();
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
result = -1;
}
return result;
}
Upvotes: 0
Reputation: 5856
If anyone has this problem, there are two easy fixes:
Inherits
portion exactly matches your project's namespace, along with the Global
type. Right click your project properties to check your namespace. So if you're application's namespace is MyProject.Web
, you should have Inherits="MyProject.Web.Global"
here.Upvotes: 1
Reputation: 10
I have spent the spent the last 2 days fighting with this error. This is my scenario and how I solved it. (and I code in VB.. not as advanced as most of you guys and gals.)
1) I added the web code folder to my project.
2) I created a dynamic data entity which created the model1.vb file containing the public class CEPTEntities
3) I set the Global.asax file routes per instructions I found. DefaultModel.RegisterContext(GetType(CEPSEntities), New ContextConfiguration() With _{.ScaffoldAllTables = True})
3a) CEPSEntitities is the name of my data Entity model. Then I verified the connection string was correct in my web.config file
4) Then I opened the properties of the modle1.vb file and changed the build action from Content (which it defaulted too) to compile.
5) Then a did a clean and rebuild and my application FINALLY opened in IE..
Hope this saves others a LOT of headache.
Upvotes: 0
Reputation: 3315
The global.asax actually has 2 files attached to it, a markup and a codebehind.
If you right click the file you can select view markup, my guess is there is a namespace or name mismatch somewhere in that line.
If not could you post your global.asax.cs & markup (should only be 1 file)?
Edit:
I have no immediate explanation for why you are getting this result.
Could you use a dll reflector program to scan your website's dll for the global type and it's namespace to verify it's correctly build into a dll?
You could use this program : download link for ILSpy
Upvotes: 0
Reputation: 3618
Right click your Web Project, go to Properties, and check that the Assembly name and Root namespace are "EnableWebApp"
Upvotes: 0