Exercise: Build and Load a .NET Assembly in AutoCAD
 
 
 

Now that you have a created a project and defined a command, you are almost ready to execute the command in AutoCAD. Before you can execute the command in AutoCAD, you need to first compile or build a .NET assembly file for your project.

For this exercise, you will be generating a Debug version of the project but you will not learn about using the Debug environment at this time. For more information on debugging a project, see the documentation that comes with your development environment. To load use the Debug environment with AutoCAD, see Load an Assembly into AutoCAD.

If you want to distribute your project for others to use, you will need to build a .NET assembly from your project. For more information on sharing your .NET assembly with others, see Distribute Your Application.

Once a .NET assembly is built, you can then load it into AutoCAD with the NETLOAD command.

To build a project and load a .NET assembly into AutoCAD

  1. In Microsoft Visual Studio, click Build menu Build MyFirstProject.

    The project should build successfully, unless something is wrong with the code in the project. Look at the Output window for information on the build status of the project. The location of the MyFirstProject.dll file that is built is also displayed in the Output window.

  2. Start AutoCAD if it is not already running.
  3. In AutoCAD, at the Command prompt, enter netload and press Enter.
  4. In the Choose .NET Assembly dialog box, browse to the location of the MyFirstProject.dll that is displayed in the Output window in Microsoft Visual Studio and select it. Click Open.
  5. At the Command prompt, enter adskgreeting and press Enter.

    A new MText object is created at the coordinates 2,2 with the text string “Greetings, Welcome to the AutoCAD .NET Developer's Guide“.