从 .Net 进程启动 AutoCAD 2015 [英] Launch AutoCAD 2015 from .Net process

查看:34
本文介绍了从 .Net 进程启动 AutoCAD 2015的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从 .Net 进程加载 AutoCAD 2015,以便我可以向文档发送命令以创建/修改块.

I was trying to load AutoCAD 2015 from .Net process so that I can send commands to the document to create/modify blocks.

我尝试了这两种方法,但它们似乎都不起作用.

I tried both of these approaches but none of them seems to work.

第一种方法:

AcadApplication app = new AcadApplication();
app.Visible = true;

第二种方法:

var t = Type.GetTypeFromProgID("AutoCAD.Application", true);
dynamic obj = Activator.CreateInstance(t, true);

在这两种情况下,我都遇到了 COM 异常.有什么帮助吗?

In both of the cases I am getting COM exception. Any help?

它不是评论中提到的重复,我已经尝试了 此处.

It's not a duplicate as mentioned in comments, I have tried both approaches mentioned in here.

COM 异常 -

使用 CLSID 检索组件的 COM 类工厂{0B628DE4-07AD-4284-81CA-5B439F67C5E6}由于以下原因失败错误:80080005 服务器执行失败(来自 HRESULT 的异常:0x80080005 (CO_E_SERVER_EXEC_FAILURE)).

Retrieving the COM class factory for component with CLSID {0B628DE4-07AD-4284-81CA-5B439F67C5E6} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).

推荐答案

最后我能够让它为我运行.(在这里发帖人不得不像我一样浪费时间)

Finally I was able to make it run for me. (Posting here so on one had to waste time like I did)

虽然不确定什么是确切的问题.奇怪的是,以普通用户身份运行 VS 2013 工作正常,但如果我以管理员身份运行它,它总是因上述 COM 异常而失败.

Not sure what was an exact issue though. Strangely, running VS 2013 as normal user worked fine but in case I run it as an administrator, it always fails with above mentioned COM exception.

这篇关于从 .Net 进程启动 AutoCAD 2015的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆