You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

关于global.asax无法加载类型的Parser Error技术求助

Global.asax解析错误:Could not load type 'WorldsStrongestProgrammer2024App.Global'

问题详情

ASP.NET应用此前可正常部署到Web服务器,目前仅能本地运行,生产服务器部署后触发如下解析错误:

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 'WorldsStrongestProgrammer2024App.Global'.

Source Error:

Line 1: <%@ Application CodeBehind="Global.asax.cs" Inherits="WorldsStrongestProgrammer2024App.Global" Language="C#" %>

Source File: /global.asax Line: 1

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4700.0

已尝试操作:

  • 将CodeBehind替换为CodeFile,但后置类无法编译
  • 多次清理bin目录并重建解决方案,问题未解决

解决建议

  • 检查程序集部署:确认生产服务器bin目录中存在包含WorldsStrongestProgrammer2024App.Global类型的项目dll文件。若缺失,重新发布时确保勾选依赖的"复制本地"选项,或手动上传编译后的dll到服务器bin目录。
  • 核对命名空间与类名:检查Global.asax.cs中的命名空间、类名是否与Global.asax里Inherits属性完全一致,注意C#大小写敏感特性。
  • 调整IIS应用池配置:确保应用池的.NET Framework版本与项目目标版本匹配(当前为4.0/4.8),同时验证"启用32位应用程序"选项是否与项目编译平台一致。
  • 确认发布配置:使用Visual Studio发布时,选择正确的目标框架,且发布模式为"Release",避免编译过程遗漏程序集。
  • 修正文件生成设置:改回CodeBehind指令,检查Global.asax.cs的"生成操作"是否设为"编译"(右键文件-属性查看),CodeBehind仅能引用编译后的类。

内容的提问来源于stack exchange,提问作者PJ Martin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.24 08:33:15