乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 105|回复: 5

Marshal.GetActiveObject("AutoCAD.Application")报错

[复制链接]

44

主题

185

帖子

8

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
361
发表于 2015-4-9 16:14:00 | 显示全部楼层 |阅读模式
换了win8的新电脑,继续做检查图面的程序,通过调用app,com,但是
            Autodesk..Interop.AcadApplication AcadApp;
            AcadApp = (AcadApplication)System.Runtime.InteropServices.Marshal.GetActiveObject("AutoCAD.Application");
C#写的 CAD 版本为06
第二句却不好使了,无法获取当前运行的CAD,很纳闷,大神解惑啊!
错误如下
未处理 System.Runtime.InteropServices.COMException
  HResult=-2147221021
  Message=操作无法使用 (异常来自 HRESULT:0x800401E3 (MK_E_UNAVAILABLE))
  Source=mscorlib
  ErrorCode=-2147221021
  StackTrace:
       在 System.Runtime.InteropServices.Marshal.GetActiveObject(Guid& rclsid, IntPtr reserved, Object& ppunk)
       在 System.Runtime.InteropServices.Marshal.GetActiveObject(String progID)
       在 承包项目资料整理.Form1.全面检查图形问题ToolStripMenuItem_Click(Object sender, EventArgs e) 位置 C:\Users\Administrator\Desktop\承包项目资料整理\承包项目资料整理\承包项目资料整理\Form1.cs:行号 2528
       在 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(IntPtr 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)
       在 盐亭承包项目资料整理.Program.Main() 位置 C:\Users\Administrator\Desktop\承包项目资料整理\承包项目资料整理\承包项目资料整理\Program.cs:行号 18
       在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException:
回复

使用道具 举报

32

主题

651

帖子

8

银币

中流砥柱

Rank: 25

铜币
779
发表于 2015-4-9 16:26:00 | 显示全部楼层
AutoCAD 2012 : ("AutoCAD.Application.18.2");
回复

使用道具 举报

44

主题

185

帖子

8

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
361
发表于 2015-4-9 16:49:00 | 显示全部楼层

是WIN8 64位系统下可以吗?
CAD2006又该如何写呢
回复

使用道具 举报

44

主题

185

帖子

8

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
361
发表于 2015-4-9 22:36:00 | 显示全部楼层

sieben兄台,求教啊!
回复

使用道具 举报

32

主题

651

帖子

8

银币

中流砥柱

Rank: 25

铜币
779
发表于 2015-4-10 08:32:00 | 显示全部楼层
64 Win7 试过 AutoCAD 2012 : ("AutoCAD.Application.18.2");
Win8 没试过
AutoCAD 2006 : ("AutoCAD.Application.16.2");
回复

使用道具 举报

44

主题

185

帖子

8

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
361
发表于 2015-4-10 09:09:00 | 显示全部楼层

谢谢,我打算换系统咯。不过WIN8真的界面很舒服
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-6-28 19:31 , Processed in 0.250133 second(s), 64 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表