求助 在 cadjiaohu.Form1.查询ToolStripMenuItem1_Click(Object sender, EventArgs e) 位置 E:\vs\cadjiaohu\Form1.cs:行号 113只能说到里了,你也不贴有用的代码,这些代码什么也看不出来? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;using Autodesk.AutoCAD.Interop;using Autodesk.AutoCAD.Interop.Common;using System.Reflection;using Microsoft.VisualBasic.ApplicationServices;namespace cadjiaohu{ public partial class Form1 : Form { AcadLine returnLine; AcadPoint returnPointObj; AcadBlockReference returnBlock; AcadCircle returncircle; AcadText returnTextObj; AcadMText returnMTextObj; AcadSpline returnSpline; AcadLWPolyline returnPolyLine; AcadSelectionSet mySelectionSet; public Int16[] FilterType= new Int16[4]{0,0,0,0}; public object[] FilterData= new object[4]{"*","*","*","*"}; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void 新建ToolStripMenuItem_Click(object sender, EventArgs e) { try { chuangkou = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application"); } catch { chuangkou = new AcadApplication(); } finally { wenjian = chuangkou.ActiveDocument; chuangkou.BeginQuit += new _DAcadApplicationEvents_BeginQuitEventHandler(chuangkou_BeginQuit); chuangkou.Visible = true; Microsoft.VisualBasic.Interaction.AppActivate(chuangkou.Caption); } } private void chuangkou_BeginQuit(ref bool Cancel) { chuangkou = null; wenjian = null; MessageBox.Show("结束了CAD程序"); } private void 打开ToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult jieguo; jieguo = openFileDialog1.ShowDialog(); if (jieguo == DialogResult.OK) { if (openFileDialog1.FileName == null) MessageBox.Show("请选择有效的文件"); else { try { chuangkou = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application"); } catch { chuangkou = new AcadApplication(); } finally { chuangkou.BeginQuit += new _DAcadApplicationEvents_BeginQuitEventHandler(chuangkou_BeginQuit); chuangkou.Visible = true; Microsoft.VisualBasic.Interaction.AppActivate(chuangkou.Caption); } chuangkou.Application.Visible = true; wenjian = chuangkou.Documents.Open(openFileDialog1.FileName, null, null); chuangkou.BeginQuit+=new _DAcadApplicationEvents_BeginQuitEventHandler(chuangkou_BeginQuit); } } Microsoft.VisualBasic.Interaction.AppActivate(chuangkou.Caption); } private void 关闭ToolStripMenuItem_Click(object sender, EventArgs e) { chuangkou.Quit(); wenjian.Close(null,null); } private void 查询ToolStripMenuItem1_Click(object sender, EventArgs e) { richTextBox1.Text = ""; object ReturnObj=new object (); object pickPoint=new object (); string pickPrompt = "选取对象"; wenjian.Utility.GetEntity(out ReturnObj, out pickPoint, pickPrompt); 本人刚学习c#对cad的ActiveX Automation技术开发!想通过wenjian.Utility.GetEntity(out ReturnObj, out pickPoint, pickPrompt);获得cad中的对象(wenjian是定义的ducoment对象),出现未处理 System.Runtime.InteropServices.COMException Message="灾难性故障 (异常来自 HRESULT:0x8000FFFF (E_UNEXPECTED))" Source="Autodesk.AutoCAD.Interop" ErrorCode=-2147418113 StackTrace: 在 Autodesk.AutoCAD.Interop.AcadUtilityClass.GetEntity(Object& Object, Object& PickedPoint, Object Prompt) 在 cadjiaohu.Form1.查询ToolStripMenuItem1_Click(Object sender, EventArgs e) 位置 E:\vs\cadjiaohu\Form1.cs:行号 113 在 System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) 在 System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e) 在 System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) 在 System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e) 在 System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met) 在 System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met) 在 System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea) 在 System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea) 在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 在 System.Windows.Forms.Control.WndProc(Message& m) 在 System.Windows.Forms.ScrollableControl.WndProc(Message& m) 在 System.Windows.Forms.ToolStrip.WndProc(Message& m) 在 System.Windows.Forms.ToolStripDropDown.WndProc(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) 在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData) 在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) 在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) 在 System.Windows.Forms.Application.Run(Form mainForm) 在 cadjiaohu.Program.Main() 位置 E:\vs\cadjiaohu\Program.cs:行号 18 InnerException: 错误!望高手解答啊!不胜感激啊!代码如下:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Runtime.InteropServices;using Autodesk.AutoCAD.Interop;using Autodesk.AutoCAD.Interop.Common;using System.Reflection;using Microsoft.VisualBasic.ApplicationServices;namespace cadjiaohu{ public partial class Form1 : Form { AcadLine returnLine; AcadPoint returnPointObj; AcadBlockReference returnBlock; AcadCircle returncircle; AcadText returnTextObj; AcadMText returnMTextObj; AcadSpline returnSpline; AcadLWPolyline returnPolyLine; AcadSelectionSet mySelectionSet; public Int16[] FilterType= new Int16[4]{0,0,0,0}; public object[] FilterData= new object[4]{"*","*","*","*"}; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { } private void 新建ToolStripMenuItem_Click(object sender, EventArgs e) { try { chuangkou = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application"); } catch { chuangkou = new AcadApplication(); } finally { wenjian = chuangkou.ActiveDocument; chuangkou.BeginQuit += new _DAcadApplicationEvents_BeginQuitEventHandler(chuangkou_BeginQuit); chuangkou.Visible = true; Microsoft.VisualBasic.Interaction.AppActivate(chuangkou.Caption); } } private void chuangkou_BeginQuit(ref bool Cancel) { chuangkou = null; wenjian = null; MessageBox.Show("结束了CAD程序"); } private void 打开ToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult jieguo; jieguo = openFileDialog1.ShowDialog(); if (jieguo == DialogResult.OK) { if (openFileDialog1.FileName == null) MessageBox.Show("请选择有效的文件"); else { try { chuangkou = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application"); } catch { chuangkou = new AcadApplication(); } finally { chuangkou.BeginQuit += new _DAcadApplicationEvents_BeginQuitEventHandler(chuangkou_BeginQuit); chuangkou.Visible = true; Microsoft.VisualBasic.Interaction.AppActivate(chuangkou.Caption); } chuangkou.Application.Visible = true; wenjian = chuangkou.Documents.Open(openFileDialog1.FileName, null, null); chuangkou.BeginQuit+=new _DAcadApplicationEvents_BeginQuitEventHandler(chuangkou_BeginQuit); } } Microsoft.VisualBasic.Interaction.AppActivate(chuangkou.Caption); } private void 关闭ToolStripMenuItem_Click(object sender, EventArgs e) { chuangkou.Quit(); wenjian.Close(null,null); } private void 查询ToolStripMenuItem1_Click(object sender, EventArgs e) { richTextBox1.Text = ""; object ReturnObj=new object (); object pickPoint=new object (); string pickPrompt = "选取对象"; wenjian.Utility.GetEntity(out ReturnObj, out pickPoint, pickPrompt); 想用c#写一个串口通讯实现的聊天程序 C#与ACESS的插入,更新与读取 求教:ADO.NET连接字符串.和localhost的区别 一个简单的问题: 想做一个等待画面,不知该如何处理? 地*磅数据转换问题,急 spring.net事务锁表 菜菜鸟:这段代码到底出了什么问题啊,我老是找不出来 正则表达式判断的空格 若得你指点,在下感激涕零,小女也必谢谢各位叔叔阿姨。 (winform)请问怎么才能在一个窗体访问另一个窗体的组件?有代码! 关于 SpeechLib.SpVoice的EndStream事件 命令模式的命令实体若有不同参数和返回值应怎么做?
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;
using System.Reflection;
using Microsoft.VisualBasic.ApplicationServices;
namespace cadjiaohu
{
public partial class Form1 : Form
{
AcadLine returnLine;
AcadPoint returnPointObj;
AcadBlockReference returnBlock;
AcadCircle returncircle;
AcadText returnTextObj;
AcadMText returnMTextObj;
AcadSpline returnSpline;
AcadLWPolyline returnPolyLine;
AcadSelectionSet mySelectionSet;
public Int16[] FilterType= new Int16[4]{0,0,0,0};
public object[] FilterData= new object[4]{"*","*","*","*"};
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{ } private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
chuangkou = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application");
}
catch
{
chuangkou = new AcadApplication();
}
finally
{
wenjian = chuangkou.ActiveDocument;
chuangkou.BeginQuit += new _DAcadApplicationEvents_BeginQuitEventHandler(chuangkou_BeginQuit);
chuangkou.Visible = true;
Microsoft.VisualBasic.Interaction.AppActivate(chuangkou.Caption);
}
} private void chuangkou_BeginQuit(ref bool Cancel)
{
chuangkou = null;
wenjian = null;
MessageBox.Show("结束了CAD程序");
} private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
{ DialogResult jieguo;
jieguo = openFileDialog1.ShowDialog();
if (jieguo == DialogResult.OK)
{
if (openFileDialog1.FileName == null)
MessageBox.Show("请选择有效的文件");
else
{
try
{
chuangkou = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application");
}
catch
{
chuangkou = new AcadApplication();
}
finally
{
chuangkou.BeginQuit += new _DAcadApplicationEvents_BeginQuitEventHandler(chuangkou_BeginQuit);
chuangkou.Visible = true;
Microsoft.VisualBasic.Interaction.AppActivate(chuangkou.Caption);
}
chuangkou.Application.Visible = true;
wenjian = chuangkou.Documents.Open(openFileDialog1.FileName, null, null);
chuangkou.BeginQuit+=new _DAcadApplicationEvents_BeginQuitEventHandler(chuangkou_BeginQuit);
}
}
Microsoft.VisualBasic.Interaction.AppActivate(chuangkou.Caption);
} private void 关闭ToolStripMenuItem_Click(object sender, EventArgs e)
{
chuangkou.Quit();
wenjian.Close(null,null);
} private void 查询ToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Text = "";
object ReturnObj=new object ();
object pickPoint=new object ();
string pickPrompt = "选取对象";
wenjian.Utility.GetEntity(out ReturnObj, out pickPoint, pickPrompt);
想通过wenjian.Utility.GetEntity(out ReturnObj, out pickPoint, pickPrompt);获得cad中的对象(wenjian是定义的ducoment对象),出现未处理 System.Runtime.InteropServices.COMException
Message="灾难性故障 (异常来自 HRESULT:0x8000FFFF (E_UNEXPECTED))"
Source="Autodesk.AutoCAD.Interop"
ErrorCode=-2147418113
StackTrace:
在 Autodesk.AutoCAD.Interop.AcadUtilityClass.GetEntity(Object& Object, Object& PickedPoint, Object Prompt)
在 cadjiaohu.Form1.查询ToolStripMenuItem1_Click(Object sender, EventArgs e) 位置 E:\vs\cadjiaohu\Form1.cs:行号 113
在 System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
在 System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
在 System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
在 System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
在 System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
在 System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
在 System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
在 System.Windows.Forms.ToolStripDropDown.OnMouseUp(MouseEventArgs mea)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ToolStrip.WndProc(Message& m)
在 System.Windows.Forms.ToolStripDropDown.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 cadjiaohu.Program.Main() 位置 E:\vs\cadjiaohu\Program.cs:行号 18
InnerException:
错误!望高手解答啊!不胜感激啊!
代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Interop;
using Autodesk.AutoCAD.Interop.Common;
using System.Reflection;
using Microsoft.VisualBasic.ApplicationServices;
namespace cadjiaohu
{
public partial class Form1 : Form
{
AcadLine returnLine;
AcadPoint returnPointObj;
AcadBlockReference returnBlock;
AcadCircle returncircle;
AcadText returnTextObj;
AcadMText returnMTextObj;
AcadSpline returnSpline;
AcadLWPolyline returnPolyLine;
AcadSelectionSet mySelectionSet;
public Int16[] FilterType= new Int16[4]{0,0,0,0};
public object[] FilterData= new object[4]{"*","*","*","*"};
public Form1()
{
InitializeComponent();
} private void Form1_Load(object sender, EventArgs e)
{ } private void 新建ToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
chuangkou = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application");
}
catch
{
chuangkou = new AcadApplication();
}
finally
{
wenjian = chuangkou.ActiveDocument;
chuangkou.BeginQuit += new _DAcadApplicationEvents_BeginQuitEventHandler(chuangkou_BeginQuit);
chuangkou.Visible = true;
Microsoft.VisualBasic.Interaction.AppActivate(chuangkou.Caption);
}
} private void chuangkou_BeginQuit(ref bool Cancel)
{
chuangkou = null;
wenjian = null;
MessageBox.Show("结束了CAD程序");
} private void 打开ToolStripMenuItem_Click(object sender, EventArgs e)
{ DialogResult jieguo;
jieguo = openFileDialog1.ShowDialog();
if (jieguo == DialogResult.OK)
{
if (openFileDialog1.FileName == null)
MessageBox.Show("请选择有效的文件");
else
{
try
{
chuangkou = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application");
}
catch
{
chuangkou = new AcadApplication();
}
finally
{
chuangkou.BeginQuit += new _DAcadApplicationEvents_BeginQuitEventHandler(chuangkou_BeginQuit);
chuangkou.Visible = true;
Microsoft.VisualBasic.Interaction.AppActivate(chuangkou.Caption);
}
chuangkou.Application.Visible = true;
wenjian = chuangkou.Documents.Open(openFileDialog1.FileName, null, null);
chuangkou.BeginQuit+=new _DAcadApplicationEvents_BeginQuitEventHandler(chuangkou_BeginQuit);
}
}
Microsoft.VisualBasic.Interaction.AppActivate(chuangkou.Caption);
} private void 关闭ToolStripMenuItem_Click(object sender, EventArgs e)
{
chuangkou.Quit();
wenjian.Close(null,null);
} private void 查询ToolStripMenuItem1_Click(object sender, EventArgs e)
{
richTextBox1.Text = "";
object ReturnObj=new object ();
object pickPoint=new object ();
string pickPrompt = "选取对象";
wenjian.Utility.GetEntity(out ReturnObj, out pickPoint, pickPrompt);