Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
241 views
in Technique[技术] by (71.8m points)

c# - Parser Error Message: Could not create type 'xxx'

i get this error

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 

in fact i get this error when using fiddler , my original error is :

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

here is my 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;
    }
}
}

if u need more details just let me know

thanks in advance for ut time

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I had this.. fixed it.. thought I'd share

if you right click the .asmx file and select view markup you'll see it still says

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

maybe not Service1.. but won't be the class you've just made

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

save it.. try it..

worked for me..


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...