“灾难性故障”大家快来帮帮忙~~~

wlpsgh 2009-02-23 03:29:30
大家好,我用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();
}
}
}
...全文
822 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
wlpsgh 2009-04-01
  • 打赏
  • 举报
回复
在工具箱中添加组件,然后在工具箱中把组件添加到程序中.
ljh4371 2009-03-24
  • 打赏
  • 举报
回复
请问你的问题是怎么解决的?我也遇到同样的问题。郁闷之极啊。方便的话,联系我一下。qq:46947523。感激不尽!
wlpsgh 2009-02-25
  • 打赏
  • 举报
回复
感谢大家的参与和帮助!!!问题解决了~
子夜1978 2009-02-24
  • 打赏
  • 举报
回复
似乎控件过期了!
wlpsgh 2009-02-24
  • 打赏
  • 举报
回复
你好,我按照你的方法试过了,可是还是没有用啊~~~~
wlpsgh 2009-02-24
  • 打赏
  • 举报
回复
还有没有哪位高人遇到过此类问题啊? 讲来听听~~~
turejackon 2009-02-23
  • 打赏
  • 举报
回复
上次我调用一个控件时也试过同样的情况,处理不了,后能我把这个组件当作是可视化组件插入就可以了..用引入方式就不行,不知道为什么...你可以试试,在工具箱中添加组件,然后选择你注册了的那个OCX组件,然后在工具箱中把组件添加到程序中,应该就可以了.
chaye12 2009-02-23
  • 打赏
  • 举报
回复
我感觉应该是控件没装好,建议楼主再装一次!
tmd456 2009-02-23
  • 打赏
  • 举报
回复
单步调试。。
yagebu1983 2009-02-23
  • 打赏
  • 举报
回复
单步调试。。
fuyuxin19801120 2009-02-23
  • 打赏
  • 举报
回复
重新装下这个组件
baypm_1111 2009-02-23
  • 打赏
  • 举报
回复
UP
wlpsgh 2009-02-23
  • 打赏
  • 举报
回复
mycontour.SetDefaultPositionValus(800, 800, 0, 800, 0, 800);
从这行开始,只要是与ocx控件相关联的都抛出异常。
周公 2009-02-23
  • 打赏
  • 举报
回复
大家没有你手中OCX控件,所以最好的办法就是告诉调试运行找出那行出错了,这样方便大家判断原因。
wlpsgh 2009-02-23
  • 打赏
  • 举报
回复
mycontour.SetDefaultPositionValus(800, 800, 0, 800, 0, 800);
从这行开始,只要是控件相关联的都抛出异常。
yczf1836 2009-02-23
  • 打赏
  • 举报
回复
你逐行调试,错误出现在哪一行了?
xhueducls 2009-02-23
  • 打赏
  • 举报
回复
可以自己断点跟下是在哪个位置抛出的异常,在进行处理。

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧