c# - 解析器错误消息 : Could not create type 'xxx'

标签 c# .net iis extjs

我收到这个错误

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;
    }
}
}

如果你需要更多细节,请告诉我

提前感谢时间

最佳答案

我有这个..修好了..我想分享

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

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

也许不是 Service1.. 但不会是你刚刚创建的类<​​/p>

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

保存..尝试..

为我工作..

关于c# - 解析器错误消息 : Could not create type 'xxx' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6760489/

相关文章:

c# - 我能否根据用于该类的泛型类型是值类型还是引用类型,从泛型类中的函数返回不同的类型?

c# - 网页浏览器 : IDropTarget

c# - 在鼠标悬停事件上突出显示列表框项目

c# - ASP.NET Identity 在每次请求时重新生成 Identity

vb.net - 获取当前目录并在 vbscript 中运行文件?

c# - 如何将流上传到Azure媒体服务

c# - 在 C# 中创建具有 'foreach' 循环的字符串数组

c# - 将 Http header 添加到 HttpClient

.net - 使用 Framework 4.0 编译的 MakeSfxCA.exe 和 DLL

jquery - asp.net 4 jQuery Ajax 无法在 iis 中使用页面方法