oldguy 发表于 2022-7-6 22:40:55

如何创建。NET程序tha

我有一个。NET程序,该程序从autoCAD中提取信息,该程序在autoCAD 2008上运行良好,但在2011/2012年严重失败。activeX无法创建对象或被被叫方拒绝的调用失败
我使用了obj=createObject(“autodesk.Application”)
 
有人已经完成了一些可以安全创建对象的代码吗?我在互联网上搜索了很多文章,它们都没有帮助或不完整。
我需要VB。net代码而不是c#。
 
亚历克斯

Jeff H 发表于 2022-7-6 22:58:04

我猜你是在尝试这样的事情
 
 
 
http://www.theswamp.org/index.php?topic=39578.0
 

   '''' Const progIDstr As String = "AutoCAD.Application.18.1"'''---- 2011
   '''' Const progIDstr As String = "AutoCAD.Application.18.0"'''---- 2010
   Const progIDstr As String = "AutoCAD.Application.18.2" '''''' ---- 2012


Dim app As AcadApplication = Nothing
       Try
         Try
               app = Marshal.GetActiveObject(progIDstr)
               app.Visible = True
         Catch
               app = New AcadApplicationClass()
               app.Visible = True
         End Try
       Catch ex As Exception         
         Return
       End Try

oldguy 发表于 2022-7-6 23:19:57

谢谢但我没有可用的类“Marshal”或“AcadApplicationClass”。
 
我确实添加了Autodesk。AutoCAD。互操作和Autodesk。AutoCAD。互操作。常见的
到我的项目参考。

Jeff H 发表于 2022-7-6 23:38:57

 
如果您有AutoCAD 2007或至少。NET 2.0比您安装的要多。
 
 
在之前发布的链接中,查看第二次回复中的代码
 
 
您应该添加
 


Imports System.Runtime.InteropServices


 
 
Marshal类
 
 
代码中使用封送处理的部分。GetActiveObject(progIDstr)用于获取AutoCAD(如果AutoCAD已在运行)。

oldguy 发表于 2022-7-6 23:49:45

啊。。。我正在使用visual Studio 2005和Windows XP。这就是为什么我没有这些,我想我需要升级。。。。
页: [1]
查看完整版本: 如何创建。NET程序tha