好的,我试着连接到2006年,我有问题。我使用了keen(通过接口)示例,它引发了一个COM异常,但它正在创建autocad实例。我不认为这与它有关,但它创造了它。
现在,当我下载2006年的objectARX时,那里没有互操作。dll只是3个“acdbmgd”变体。。。我只是在学习如何使用c。有人能扔我一点骨头吗?这是我的代码。
- public MainForm() {
- InitializeComponent();
- IMessageFilter oldFilter = default(IMessageFilter);
- CoRegisterMessageFilter(this, oldFilter);
-
- AcadApplication acApp = GetAcApp("AutoCAD.Application.16.2");
-
- }
-
- public AcadApplication GetAcApp(string progID){
- AcadApplication acApp = null;
- try {
- acApp = (AcadApplication)Marshal.GetActiveObject(progID);
- } catch {
- try {
- Type acType = Type.GetTypeFromProgID(progID);
- acApp = (AcadApplication)Activator.CreateInstance(acType,true);
-
- } catch {
- MessageBox.Show("Cannot create object of type "" + progID + """);
- }
- }
- if (acApp != null) {
- // By the time this is reached AutoCAD is fully
- // functional and can be interacted with through code
- acApp.Visible = true;
- return acApp;
- }
- return null;
- }
|