autocad.net二次开发中visualstudio版本问题

来源:互联网 发布:python遍历json对象 编辑:程序博客网 时间:2024/06/01 11:04

Overview of Microsoft Visual Studio

Microsoft Visual Studio概述

Microsoft Visual Studio is an object-oriented programming environment that runs independently of AutoCAD. While Microsoft Visual Studio is external to AutoCAD and other applications, it is able to interact with applications that expose either a native .NET API or ActiveX/COM library.

Microsoft Visual Studio是不依赖AutoCAD运行的面向对象编程环境。虽然Microsoft Visual Studio是AutoCAD及其他应用程序的外部环境,但它能与那些公开了自己的本地.NET API或ActiveX/COM库的应用程序进行交互。

Topics in this section本节主题

·         Which Edition of Microsoft Visual Studio to Use 使用Visual Studio哪个版本

·         Use COM Interoperability with .NET 使用COM与.NET交互操作

·         Dependencies and Restrictions 依赖性及限制

 

1、Which Edition of Microsoft Visual Studio to Use使用Visual Studio哪个版本

Microsoft Visual Studio is available in multiple versions and editions. To use the .NET API for AutoCAD 2012, you need to use:

Microsoft Visual Studio有多个版本可用。要是开发AutoCAD 2012 .NET API项目,我们需要使用:

·         Microsoft Visual Studio 2010

·         Microsoft .NET Framework 4.0

Note Projects compiled with Microsoft Visual Studio 2008 with a target of Microsoft .NET Framework 3.5 should load into AutoCAD 2012 without a problem. Microsoft Visual Studio 2008 cannot be used to debug projects loaded in AutoCAD 2012; you must use Microsoft Visual Studio 2010 when debugging a project.

注意:由Microsoft Visual Studio 2008编译的目标为Microsoft .NET Framework 3.5的项目可以加载到AutoCAD2012运行没有问题。但Microsoft Visual Studio 2008不能用来调试AutoCAD 2012加载的项目,调试项目时必须使用Microsoft Visual Studio 2010。

If you are using AutoCAD 2010 or AutoCAD 2011, you should use:

如果使用的是AutoCAD 2010或AutoCAD 2011,则应选择:

·         Microsoft Visual Studio 2008 with Service Pack 1

·         Microsoft .NET Framework 3.5 with Service Pack 1

If you are using AutoCAD 2007 through AutoCAD 2009, you should use:

如果使用的是AutoCAD 2007到AutoCAD 2009,则应选择:

·         Microsoft Visual Studio 2005

·         Microsoft .NET Framework 2.0 or later (或2.0以上)

Microsoft Visual Studio is offered in two editions: for free and for pay. The free edition is known as Microsoft Visual Studio 2010 Express Edition, while the for pay editions vary by name and price due to the different development tools that are incorporated into them. Microsoft Visual Studio 2010 Professional Edition provides improved debugging over Microsoft Visual Studio 2010 Express Edition along with a number of other features. The most common edition of Microsoft Visual Studio used by developers is Microsoft Visual Studio 2010 Professional Edition.

Microsoft Visual Studio有两种版本供选择:免费版本和付费版本。免费版本众所周知就是Microsoft Visual Studio 2010 Express版,付费版本的名称和价格因整合的开发工具的不同而异。Microsoft Visual Studio 2010专业版提供了比Microsoft Visual Studio 2010 Express版改进了的调试性能及其他许多特性。开发人员最常用的Microsoft Visual Studio版本就是Microsoft Visual Studio 2010专业版。

Note While it is possible to use Microsoft Visual Studio Express with the AutoCAD .NET API, this guide assumes you are using one of the other versions such as Microsoft Visual Studio 2010 Professional Edition or Microsoft Visual Studio 2010 Premium Edition.

注意:可能有人使用Microsoft Visual Studio Express版进行AutoCAD .NET API开发,但本指南假设你使用的是Microsoft Visual Studio 2010专业版或Microsoft Visual Studio 2010高级版。

There are four main advantages to using Microsoft Visual Studio:

使用Microsoft Visual Studio的四大优势:

·         Robust and accessible development environment that has a modest learning curve. 强大易用的开发环境,轻松的学习过程;

·         VBA and VB.NET syntax are similar, which makes it an ideal environment for existing VBA users. VBA和VB.NET语法相近,是现有VBA开发人员理想的环境;

·         Visually intuitive and extensive dialog box creation tools. 直观、丰富的对话框创建工具;

·         Projects can be built as a standalone executable or DLL assembly which can then be loaded into AutoCAD for execution. 可以将项目生成为独立的可执行程序或DLL程序集,加载到AutoCAD执行;

Note Unlike VBA projects, .NET applications do not suffer from performance degradation when loaded and run in 64-bit AutoCAD.

注意:不像VBA项目,.NET应用程序加载并运行在64位AutoCAD环境时性能不会下降。

For more information on the different editions of Microsoft Visual Studio, seehttp://www.microsoft.com/vstudio andhttp://www.microsoft.com/express.

更多关于Microsoft Visual Studio不同版本的信息,见http://www.microsoft.com/vstudio 及http://www.microsoft.com/express。Please send us your comments about this page

2、Use COM Interoperability with .NET使用COM与.NET互操作

Microsoft Visual Studio can utilize both native .NET and COM interfaces in the same project. By utilizing COM interop, you can migrate existing code that might have been written in Visual Basic 6 or VBA without having to completely rewrite it. To access AutoCAD automation objects from a project created in Microsoft Visual Studio, create references to the following files:

Microsoft Visual Studio可以在同一个项目中使用本地.NET和COM两种接口,这样我们就可以移植现有的那些用VB6或VBA写的代码而不必完全重写。要想在Microsoft Visual Studio创建的项目中访问AutoCAD自动化对象,需要建立对下列文件的引用:

·         The AutoCAD 2012 type library, acax18enu.tlb, located at<drive>:\Program Files\Common Files\Autodesk Shared. AutoCAD 2012类库文件acax18enu.tlb,位于C:\ Program Files\Common Files\Autodesk Shared

·         The AutoCAD/ObjectDBX Common 18.0 type library, axdb18enu.tlb, located at<drive>:\Program Files\Common Files\Autodesk Shared. AutoCAD/ObjectDBX18.0通用类库文件axdb18enu.tlb,位于C:\ Program Files\Common Files\Autodesk Shared

Note The previous mentioned type libraries are also available as part of the ObjectARX SDK. For information on downloading and installing the ObjectARX SDK, seeComponents of the AutoCAD .NET API.

注意:前面提到的类库文件还可以从ObjectARX SDK中得到。……

These references will make the following primary interop assemblies available:

对这些类库的引用使得下列基本互操作程序集可用:

·         Autodesk.AutoCAD.Interop.dll (for AutoCAD-specific typesAutoCAD专有类型)

·         Autodesk.AutoCAD.Interop.Common.dll (for types shared by ObjectDBX host applications ObjectDBX宿主应用程序共享类型)

The interop assemblies are located in the global assembly cache; they map automation objects to their .NET counterparts.

互操作程序集位于全局程序集缓存;他们将自动化对象映射为.NET的对等对象。

After you reference the type libraries, you can declare AutoCAD-based variables in Microsoft Visual Studio, as in the following examples:

引用了这些类库,我们就可以在Microsoft Visual Studio中声明AutoCAD变量,像下面的例子:

VB.NET

Dim objAcApp As Autodesk.AutoCAD.Interop.AcadApplication

Dim objLine As Autodesk.AutoCAD.Interop.Common.AcadLine

C#

Autodesk.AutoCAD.Interop.AcadApplication objAcApp;

Autodesk.AutoCAD.Interop.Common.AcadLine objLine;

Utilizing the interop assemblies can make the transitioning your VBA projects over to VB.NET much easier. However, in order to take full advantage of everything that .NET and the AutoCAD .NET API have to offer, you will need to rewrite your existing VBA code.

应用互操作程序集使得将VBA项目转换为VB.NET项目更容易。不过,为了充分利用.NET和AutoCAD .NET API提供的全部功能,还是要重写现有VBA代码。

Create and Reference the AutoCAD Application 创建并引用AutoCAD应用程序

AutoCAD 2012 .NET applications can utilize the same type library (acax18enu.tlb) as AutoCAD automation projects. The type library is located in<drive>:\Program Files\Common Files\Autodesk Shared.

AutoCAD 2012 .NET应用程序可以和AutoCAD自动化项目一样利用相同的类库(acax18enu.tlb)。该类库位于c:\Program Files\Common Files\Autodesk Shared

AutoCAD 2012 .NET applications also use the same version-dependent ProgID for the CreateObject, GetObject, and GetInterfaceObject functions. For example, CreateObject ("AutoCAD.Application.18") allows you to create an instance of AutoCAD and get an object that represents the new instance of the application.

AutoCAD 2012 .NET应用程序的CreateObject、GetObject和GetInterfaceObject函数也使用同样的依赖版本的ProgID值。例如,CreateObject("AutoCAD.Application.18")允许我们创建一个AutoCAD的实例,并获取代表应用程序新示例的对象。

 

3、Dependencies and Restrictions依赖性及限制

Unlike ActiveX Automation, there are fewer issues with library conflicts when other applications are installed, reinstalled, or uninstalled. The reason for fewer compatibility issues is that the .NET Framework is a standardized platform. However, you can still run into dependency issues. To avoid dependency issues with the .NET Framework, be sure to use the same or an earlier version of the .NET Framework with your VB.NET or C# project that AutoCAD 2012 uses. For information on which version of the .NET Framework you should be referencing, see Which Edition of Microsoft Visual Studio to Use.

不像ActiveX Automation,在其他程序安装、重装及卸载时很少出现库冲突的情形。很少出现兼容问题的原因在于.NET Framework是一个标准化的平台。不过,还是会遇到依赖性问题。要避免.NET Framework依赖性问题,应确保使用与AutoCAD2012所用.NET Framework相同或更早的版本来开发VB.NET或C#项目。更多信息见使用Microsoft Visual Studio哪个版本。

0 0
原创粉丝点击