如何修复此错误?
我正在运行 .NET Framework v4.0.30319,因此该框架应该不是问题。我没有使用任何 DLL 文件或 bin 目录。如果我使用 VS2010 对整个网站使用表单例份验证,我该如何设置 IIS/虚拟目录?
描述:解析服务此请求所需的资源时发生错误。请查看以下具体的解析错误详细信息并适当修改您的源文件。
Parser Error Message: Could not load type 'ACAWebApplication.Pages.State_Carrier_Search'.
Source Error:
Line 1: <%@ Page Title="ACA Web App - State Carrier Search" Language="C#"
MasterPageFile="~/Pages/User.Master" AutoEventWireup="true"
CodeBehind="State_Carrier_Search.aspx.cs"
Inherits="ACAWebApplication.Pages.State_Carrier_Search" %>
Line 2: <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent"
runat="server">
Line 3: <style type="text/css">
Source File: /Pages/State_Carrier_Search.aspx Line: 1
The Codebehind for State_Carrier_Search.aspx.cs file:
namespace ACAWebApplication.Pages
{
public partial class State_Carrier_Search : System.Web.UI.Page
{
protected void Page_LoadS(object sender, EventArgs e)
State_Carrier_Search.aspx文件代码如下:
<%@ Page Title="ACA Web App - State Carrier Search" Language="C#" MasterPageFile="~/Pages/User.Master" AutoEventWireup="true" CodeBehind="State_Carrier_Search.aspx.cs" Inherits="ACAWebApplication.Pages.State_Carrier_Search" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
谢谢!
最佳答案
你不能将类和命名空间命名为相同的
这是你的问题
namespace ACAWebApplication.Pages
{
public partial class ACAWebApplication.Pages.State_Carrier_Search : System.Web.UI.Page
{
解析器看到 ACAWebApplication.PAges 命名空间和 ACAWebApplication.Pages 类名。这可能是合法的,但这是非常错误的
从类名中删除 ACAWebApplication.PAges,它应该可以工作。它是自动生成的还是您已经从类名中提取了 namespace 。无论哪种方式改变它
阅读 Eric lippert musings on it - whole series quite enlightening
关于c# - ASP.NET C# - 源文件分析错误 - 无法加载继承类型文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5264683/