分析器错误消息:无法创建类型’xxx’
我收到这个错误
Parser Error Message: Could not create type 'charts.lineChartData'. Source Error: Line 1: 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 chartItems = new List(); 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 ..但不会是你刚刚上课的
<%@ WebService Language="C#" CodeBehind="MyService.asmx.cs" Class="MyProject.MyService" %>
保存吧..试试吧..
为我工作..
当你的代码没有构建时,你通常会得到它,即没有dll所以我无法加载处理程序类型。
当我的项目输出目录不是bin时,我使用Visual Studio Development Server遇到此错误
我的一个DLL有不同平台的版本(x86,x64),所以我创建了相应的配置,他们默认输出目录如下:
bin\x86\Debug bin\x64\Debug
但Visual Studio开发服务器仍尝试从bin \文件夹加载二进制文件,当然也失败了。
我通过在调试配置中指定bin \ output文件夹来修复此问题。