I am using the Office Web Components (Interop.OWC10.dll) to generate agrapth on my ASP.NET application and am getting the following messagefor some reason...
System.Runtime.InteropServices.COMException (0x80040154) Office Web Components
I have also referenced the following .dll's...
Interop.ADODB.dll
Interop.MSComctlLib.dll
This error occurs in a method I have called GenerateGraph(). The code contained in this method is as follows...
private void GenerateGraph()
{
try
{
//First create a ChartSpace object to hold the chart
OWC10.ChartSpaceClass objCSpace = newOWC10.ChartSpaceClass();
//Add a chart in the ChartSpace. The Add methodreturns a chart object.
OWC10.ChChart objChart = objCSpace.Charts.Add(0);
//Specify the type of the graph to be displayed. Thetype of the graph is specified by the enumerated values inOWC.ChartChartTypeEnum
objChart.Type =OWC10.ChartChartTypeEnum.chChartTypeLine;
//Give title to graph.
objChart.HasTitle = true;
objChart.Title.Caption = "Discontinuity Report";
objChart.Title.Font.Bold = true;
//Give the caption for the X axis and Y axis of thegraph
objChart.Axes[0].HasTitle = true;
objChart.Axes[0].Title.Caption = "Response Time";
objChart.Axes[0].HasTickLabels = true;
objChart.Axes[0].TickLabelSpacing = 5;
//Give the caption for the X axis and Y axis of thegraph
objChart.Axes[1].HasTitle = true;
objChart.Axes[1].Title.Caption = "Calls";
//Populate the Literal Strings For the data
//The categories and values can be given as literalstring with values separated by tabs. With these three values we candraw a single line.*/
//Dim strSeriesName As String = "Responses"
string strCategory = "";
string strValue = "";
//Add a series to the chart's series collection
objChart.SeriesCollection.Add(0);
FillDataStrings(ref strCategory, ref strValue);
//Give the name of the series
objChart.SeriesCollection[0].SetData(OWC10.ChartDimensionsEnum.chDimSeriesNames,System.Convert.ToInt32(OWC10.ChartSpecialDataSourcesEnum.chDataLiteral),""); //strSeriesName)
//Give the Categories
objChart.SeriesCollection[0].SetData(OWC10.ChartDimensionsEnum.chDimCategories,System.Convert.ToInt32(OWC10.ChartSpecialDataSourcesEnum.chDataLiteral),strCategory);
//Give The values
objChart.SeriesCollection[0].SetData(OWC10.ChartDimensionsEnum.chDimValues,System.Convert.ToInt32(OWC10.ChartSpecialDataSourcesEnum.chDataLiteral),strValue);
//Now a chart is ready to export to a GIF.
string strFilename = "PerformanceGraph" +DateTime.Now.ToString("ddMMyyyyhhmmss") + 1000 * 1000 + ".gif";
string strAbsolutePath = (Server.MapPath(".")) +"\\TempFiles\\" + strFilename;
//string strAbsolutePath = (
objCSpace.ExportPicture(strAbsolutePath, "GIF", 800,480);
//Create a relative path to the GIF file.
//If an absolute path is used instead of a relativepath, the file will not be displayed in the client machines as the fileis created in the server, not in the client. */
//string AppName =
//string strAppPath =Rainbow.Settings.Path.ApplicationPhysicalPath + "TempFiles\\" +strFilename;
string strAppPath =Rainbow.Settings.Path.ApplicationRoot + "/TempFiles/" + strFilename;
//Add the image into the placeholder.
string strImageTag = "<IMG SRC=\"" + strAppPath +"\" />";
phChart.Controls.Add(newLiteralControl(strImageTag));
Log.ApplicationLog.Write("Graph paths: \n\rApp Path:" + strAppPath + "\n\rImage Tag Path: " + strImageTag);
}
catch (Exception E)
{
Log.ApplicationLog.Write("Error: " + E);
}
}
For the life of me I can't seem to find out where exactly theproblem lies (though I have found some sources online that state thatthe the COM object may not be registered - I doubt it is this though asit would have been stated in the error message).
Hope someone can help me here.
Tryst
Which line of code is producing that error?
Did you try registering it?
regsvr32 xyz.dll
It doesn't exactly state which line it is one. It just references the method in which the error is called.
The Office Web Components were already installed as we had previous reports using the Office Web Components.
I'm not really sure what the problem can be? Are there any other possible external factors that may be causing this?
Thanks
Tryst
Try the link below for PInvoke(platform invoke). Hope this helps.
http://www.pinvoke.net
I use OWC all over the place, seems to me I get a line number. How about trying this, walk through each line of code and let us know which it dies on?
Or...
I have a little OWC Chart Helper class that I just posted at my blog. Its not very well documented, but perhaps it'll help you out? I write classes like this to help me use complicated stuff like OWC a bit more easily. I also have an Excel helper that is an interface implementing both OWC and Excel models, I'll post it soon. I need to clean these things up.
http://spaces.msn.com/members/mutethis/Blog/cns!1pqaRX9UNoMK6pqNr__0Gnqw!167.entry
HTH
0 comments:
Post a Comment