Visual Studio 无法从 global.asax 加载类型 [英] Visual Studio cannot load type from global.asax

查看:35
本文介绍了Visual Studio 无法从 global.asax 加载类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道之前已经提出过这个问题,但可用的解决方案并没有解决我的问题.

I know this issue has been raised before, but the solutions available have not resolved my problem.

我的解决方案中有一个不是我写的 global.asax 文件.cs 文件中的命名空间和类与继承命名空间和类匹配.

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.

全球.asax"<%@ Application Codebehind="Global.asax.cs" Inherits="EnableWebApp.Global" Language="C#" %>"

Global.asax "<%@ Application Codebehind="Global.asax.cs" Inherits="EnableWebApp.Global" Language="C#" %>"

Global.asax.cs命名空间 EnableWebApp{公共类全局:System.Web.HttpApplication{

Global.asax.cs namespace EnableWebApp { public class Global : System.Web.HttpApplication {

推荐答案

过去 2 天我一直在与这个错误作斗争.这是我的场景以及我如何解决它.(我用 VB 编写代码.不像你们大多数人那么先进.)

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) 我将 Web 代码文件夹添加到我的项目中.

1) I added the web code folder to my project.

2) 我创建了一个动态数据实体,它创建了包含公共类 CEPTEntities 的 model1.vb 文件

2) I created a dynamic data entity which created the model1.vb file containing the public class CEPTEntities

3) 我按照找到的说明设置了 Global.asax 文件路由.DefaultModel.RegisterContext(GetType(CEPSEntities), New ContextConfiguration() With _{.ScaffoldAllTables = True})

3) I set the Global.asax file routes per instructions I found. DefaultModel.RegisterContext(GetType(CEPSEntities), New ContextConfiguration() With _{.ScaffoldAllTables = True})

3a) CEPSEntitities 是我的数据实体模型的名称.然后我验证了我的 web.config 文件中的连接字符串是正确的

3a) CEPSEntitities is the name of my data Entity model. Then I verified the connection string was correct in my web.config file

4) 然后我打开了 modle1.vb 文件的属性并将构建操作从 Content(它也是默认的)更改为编译.

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) 然后做了一个清理和重建,我的应用程序终于在 IE 中打开了..

5) Then a did a clean and rebuild and my application FINALLY opened in IE..

希望这可以为其他人省去很多麻烦.

Hope this saves others a LOT of headache.

这篇关于Visual Studio 无法从 global.asax 加载类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆