【问题标题】:Parser Error Message: Could not create type 'xxx'解析器错误消息:无法创建类型“xxx”
【发布时间】:2011-07-20 10:30:11
【问题描述】:

我得到这个错误

Parser Error Message: Could not create type 'charts.lineChartData'.

Source Error: 

Line 1:  <%@ WebHandler Language="C#" CodeBehind="lineChartData.ashx.cs" Class="charts.lineChartData" %>

Source File: /WebSiteNetPas/lineChartData.ashx    Line: 1 

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 

实际上我在使用 fiddler 时遇到了这个错误,我原来的错误是:

Uncaught ReferenceError: lineChartData is not defined                   lineChart.js:20
http://localhost/WebSiteNetPas/lineChartData.ashx?proxy 500 (Internal Server Error)

这是我的 lineChartData.ashx.cs

using System;
using System.Web;
using System.Linq;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using System.Web.Script.Serialization;

namespace charts
{
    public class lineChartData : IHttpHandler
    {

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.Write("Hello World");
    }

    public bool IsReusable
    {
        get
        { return false; }
    }

    static string ConvertToJson()
    {
        lineChartClass c = new lineChartClass();

        double[] json = new double[4];

        //Array.Copy(c.piedata(), json, 4);
        c.piedata().CopyTo(json, 0);

        List<ChartItem> chartItems = new List<ChartItem>();

        chartItems.Add(new ChartItem() { Name = "Low", Data1 = json[0].ToString() });
        chartItems.Add(new ChartItem() { Name = "Moderate", Data1 = json[1].ToString() });
        chartItems.Add(new ChartItem() { Name = "Critical", Data1 = json[2].ToString() });
        chartItems.Add(new ChartItem() { Name = "High", Data1 = json[3].ToString() });
        string result = new JavaScriptSerializer().Serialize(chartItems);
        //result = "{ name: \"Low\", data1: " + json[0] + "}" + ",{ name: \"Moderate\", data1: " + json[1] + "}" + ",{ name: \"Critical\", data1: " + json[2] + "}" + ",{ name: \"High\", data1: " + json[3] + "}";

        return result;
    }
}
}

如果您需要更多详细信息,请告诉我

提前感谢ut时间

【问题讨论】:

    标签: c# .net iis extjs


    【解决方案1】:

    我有这个.. 修复它.. 想我会分享

    如果您右键单击 .asmx 文件并选择查看标记,您会看到它仍然显示

    <%@ WebService Language="C#" CodeBehind="MyService.asmx.cs" Class="MyProject.Service1" %>
    

    也许不是 Service1.. 但不会是你刚刚制作的课程

    <%@ WebService Language="C#" CodeBehind="MyService.asmx.cs" Class="MyProject.MyService" %>
    

    保存..试试看..

    为我工作..

    【讨论】:

    • 还要注意 Class 属性中的文本区分大小写:Class="MyProject.MyService" 与 Class="MyProject.myService" 不同。我自己也被这个发现了。
    【解决方案2】:

    当我的项目输出目录不是 bin 时,我在使用 Visual Studio Development Server 时遇到了这个错误\

    我的一个 DLL 有不同平台(x86、x64)的版本,所以我创建了相应的配置,它们默认输出目录如下:

    bin\x86\Debug 
    bin\x64\Debug
    

    但 Visual Studio 开发服务器仍然尝试从 bin\ 文件夹加载二进制文件,当然失败了。

    我通过在调试配置中指定 bin\ 输出文件夹解决了这个问题。

    【讨论】:

    • 在挖掘了一段时间后,这是为我完成的修复。谢谢!
    【解决方案3】:

    当你的代码没有构建时,你通常会得到它,即没有 dll,所以我无法加载处理程序类型。

    【讨论】:

    • 但我确实构建了项目,并且 dll 在那里我没有更改目录或任何东西
    • 我想是的。;我如何确定?
    • @Astrocybernaute - 检查项目的设置。
    • 问题是它无法加载处理程序文件的类型。如果 DLL 在那里并且它们是正确的版本,那么看起来 DLL 不包含处理程序的类型,即它们是旧的 DLL。重建并重新部署网站。
    • @astrocybernaute,哇。您接受了一个无效的答案?
    猜你喜欢
    • 1970-01-01
    • 2015-09-18
    • 1970-01-01
    • 1970-01-01
    • 2020-06-15
    • 2019-11-02
    • 2021-11-14
    • 2014-12-03
    • 1970-01-01
    相关资源
    最近更新 更多