ASP.NET 繪出統計圖表 - ZedGraph Win / Web - III - Parser Error

摘要:ASP.NET 繪出統計圖表 - ZedGraph Win / Web - III - Parser Error

  天阿~怎麼會有 Parser Error 的問題阿?我明明都按照之前的步驟作哩,而且在另外一個專案也有成功的執行起來,怎麼這個專案怎麼試都說 Parser Error 呢?

這個問題困擾我3小時,害我午餐都吃不好,肚子還悶悶的......(其實是昨天的豆皮酸掉了)

 
來看一下問題的徵狀

錯誤訊息:「Parser Error 
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 
Parser Error Message: Could not load file or assembly 'ZedGraph, Version=5.1.2.878, Culture=neutral, PublicKeyToken=02a83cbd123fcd60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

一樣很難看出錯誤在哪吧...呵呵

到 code-behind 去看居然連 RenderGraph 事件都看不到
 
而且 Error List 居然連<cc1:ZedGraphWeb ID="ZedGraphWeb1" runat="server"></cc1:ZedGraphWeb>
cc1 說不認得,ID大寫都提出警告

啥米碗糕阿...
 
要說答案了,答案藏在下圖裡
 
 
 

 
看不出來再看檔案總管

 
------------------
原因是:你以 ZedGraph 名稱作為專案名稱時,當你編譯執行時會在 bin 目錄下產生 「專案名稱.dll」的函式檔,而這時因為你用了 ZedGraphWeb 物件,他會自動在 bin 目錄下新增 2個 dll,此一名稱重複造成了 Parser Error 的錯誤問題。

 
解決方法:就是專案名稱不要跟 ZedGraph 一樣,即使測試時也要避開名稱重複造成的錯誤。

 
~ End

------怕這篇太沒營養,在貼另外一個例子-------

Dim myPane As GraphPane = masterPane(0)
' Set the title and axis labels
myPane.Title.Text = "Cat Stats"
myPane.YAxis.Title.Text = "Big Cats"
myPane.XAxis.Title.Text = "Population"
' Make up some data points
Dim labels() As String = {"Panther""Lion""Cheetah""Cougar""Tiger""Leopard"}
Dim x() As Double = {100, 115, 75, 22, 98, 40}
Dim x2() As Double = {120, 175, 95, 57, 113, 110}
Dim x3() As Double = {204, 192, 119, 80, 134, 156}
' Generate a red bar with "Curve 1" in the legend
Dim myCurve As BarItem = myPane.AddBar("Here", x, Nothing, Color.Red)
' Fill the bar with a red-white-red color gradient for a 3d look
myCurve.Bar.Fill = New Fill(Color.Red, Color.White, Color.Red, 90.0F)
' Generate a blue bar with "Curve 2" in the legend
myCurve = myPane.AddBar("There", x2, Nothing, Color.Blue)
' Fill the bar with a Blue-white-Blue color gradient for a 3d look
myCurve.Bar.Fill = New Fill(Color.Blue, Color.White, Color.Blue, 90.0F)
' Generate a green bar with "Curve 3" in the legend
myCurve = myPane.AddBar("Elsewhere", x3, Nothing, Color.Green)
' Fill the bar with a Green-white-Green color gradient for a 3d look
myCurve.Bar.Fill = New Fill(Color.Green, Color.White, Color.Green, 90.0F)
' Draw the Y tics between the labels instead of at the labels
myPane.YAxis.MajorTic.IsBetweenLabels = True
' Set the YAxis labels
myPane.YAxis.Scale.TextLabels = labels
' Set the YAxis to Text type
myPane.YAxis.Type = AxisType.Text
' Set the bar type to stack, which stacks the bars by automatically accumulating the values
myPane.BarSettings.Type = BarType.Stack
' Make the bars horizontal by setting the BarBase to "Y"
myPane.BarSettings.Base = BarBase.Y
' Fill the axis background with a color gradient
myPane.Chart.Fill = New Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F)
masterPane.AxisChange(g)



---O2---