“灾难性故障”大家快来帮帮忙~~~
大家好,我用c#调用OCX控件(contourOCX)时出现以下异常:
“灾难性故障 (异常来自 HRESULT:0x8000FFFF (E_UNEXPECTED))”,谁知道这个问题怎么解决啊?我是新手,希望有经验人士帮帮忙啊!!!
代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace WindowsApplicationTest
{
public partial class Form1 : Form
{
CONTOUROCXLib.ContourOCXClass mycontour = new CONTOUROCXLib.ContourOCXClass();
//CONTOUROCXLib.ContourOCX mycontour = new CONTOUROCXLib.ContourOCX();
public Form1()
{
InitializeComponent();
}
void SetContourLinesColor()
{
mycontour.ClearColorClass();
mycontour.AddNewElementToColorClass(0xff0000);
mycontour.AddNewElementToColorClass(0x00ff00);
mycontour.AddNewElementToColorClass(0x0000ff);
mycontour.ResetContoursColor();
}
void SetPolygonsColor()
{
// change color from red to green,then from green to blue
mycontour.ClearColorClass();
mycontour.AddNewElementToColorClass(0xff0000);
mycontour.AddNewElementToColorClass(0x00ff00);
mycontour.AddNewElementToColorClass(0x0000ff);
mycontour.ResetPolygonsColor(0xffffff);
}
private void button1_Click(object sender, EventArgs e)
{
int Smooth = 5;
mycontour.SetDefaultPositionValus(800, 800, 0, 800, 0, 800);
mycontour.InitialRandom(4, 5, 1, 5);
mycontour.FreeData();
mycontour.SetDefaultPositionValus(100, 100, 0, 800, 0, 800);
mycontour.InitialRandomKrigingOK(-1, 30, 1, Smooth, -1);
//读取文本中数据
string path1 = "E:\\Surfer\\等值线表.txt";
int PointCount = mycontour.AddRandomPointsFromFile(ref path1);
SetContourLinesColor();
//set position values
mycontour.ResetContourPosition();
//绘制等值线
string path2 = "E:\\Surfer\\等值线表.txt";
mycontour.AddRandomPointsFromFile(ref path2);
mycontour.CalculateRandom();
mycontour.SetDefaultPositionValus(800,800,1,800,0,800);
//生成等值面
int suc=0;
mycontour.ConvertToPolygon(ref suc);
//set the color
SetPolygonsColor();
//转换成.shp文件
string path3="E:\\Surfer";
string type1 = "line";
string type2 = "polygon";
string newFieldName = "newField";
string FieldType = "float";
mycontour.InitializeSHPFile(ref path3,ref type1);//.shp文件
mycontour.AddAppendedField(ref type1,ref newFieldName, ref FieldType, 10);
mycontour.CreateShapeFile();
mycontour.InitializeSHPFile(ref path3,ref type2);
mycontour.CreateShapeFile();
}
}
}