问题
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 {
回答1:
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.
回答2:
If anyone has this problem, there are two easy fixes:
- Delete the Global.asax and add a new one via Visual Studio's Add -> New Item functionality, it will add the correct namespace/type combination
- Ensure that the
Inheritsportion exactly matches your project's namespace, along with theGlobaltype. Right click your project properties to check your namespace. So if you're application's namespace isMyProject.Web, you should haveInherits="MyProject.Web.Global"here.
回答3:
Right click your Web Project, go to Properties, and check that the Assembly name and Root namespace are "EnableWebApp"
回答4:
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
来源:https://stackoverflow.com/questions/19029104/visual-studio-cannot-load-type-from-global-asax