我得到這個錯誤分析器錯誤信息:無法創建類型「XXX」
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
其實使用招,當我得到這個錯誤,我原來的錯誤是:
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;
}
}
}
如果u需要更多的細節只是讓我知道
預先感謝UT時間
thnx。確認作品。 – b0x0rz
還要注意,Class屬性中的文本區分大小寫:Class =「MyProject.MyService」與Class =「MyProject.myService」不同。我被自己發現了。 – SausageFingers