使用 Autodesk 库中的数据类型后,C# 中的控制台应用程序无法立即执行 [英] Console app in C# fails to execute as soon as data types in Autodesk libraries are used

查看:22
本文介绍了使用 Autodesk 库中的数据类型后,C# 中的控制台应用程序无法立即执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 C# 开发一些 AutoCAD 附加组件,我希望先在控制台应用程序中工作/调试我的类,直到我准备好在 AutoCAD 中实现该功能./dot net库无法卸载,每次修改代码都需要重启/重新加载acad/有趣的是,我发现一旦我声明了一个使用 autocad 数据类型的变量,我的控制台应用程序就拒绝运行,并且我在 Visual Studio 中显示应用程序处于中断模式"屏幕.例如,此代码不会运行:

 使用系统;使用 Autodesk.AutoCAD.Geometry;命名空间测试控制台{课程计划{静态无效主(字符串 [] args){Console.WriteLine("嗨");Point2dp;Console.ReadKey();}}}

尝试引用 Autodesk C3D 2016 dll 库.有没有人解释这里发生的事情和/或任何解决方法?谢谢

解决方案

要调试您的 AutoCAD 附加组件代码,您需要创建一个引用 Autodesk CAD 2016 Sdk 库的 C# 类库项目,并将您的代码封装在公共方法上声明为

I'm developing some AutoCAD add-ons in C# and I was hoping to work/debug my classes in a console application first until I'm ready to implement the functionality inside AutoCAD. /dot net libraries cannot be unloaded and one needs to restart/reload acad each time the code is modified/ Interestingly I'm finding that as soon as I declare a variable which uses an autocad data type my console app refuses to run and Im presented with a "the application is in break mode" screen in visual studio. For example this code does not run:

  using System;
  using Autodesk.AutoCAD.Geometry;
  namespace TestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hi");
            Point2d p;            
            Console.ReadKey();
        }
    }
}

Trying this referencing Autodesk C3D 2016 dll libraries. Does anyone have an explanation of what is going on here and/or any workarounds? thnks

解决方案

To debug your AutoCAD Add-On code, you need to create a C# Class Library Project referencing the Autodesk CAD 2016 Sdk Libraries, and encapsulate your code on public method that declared with CommandMethodAttribute. With this method declared with CommandMethod it's the be your trigger between the AutoCAD prompt command and your Add-On code.

public class AcadCommands
{
    [CommandMethod("TriggerCmd")]
    public void TriggerCommand
    {
        Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
        ed.WriteMessage("Hi");
        Point2d p;
    }
}

Note: at your Visual Studio Project Properties, you need to configure to start debug pointed to acad.exe and when the AutoCAD applications starts, open some DWG and prompt the "NETLOAD" command to include your debbugable compiled DLL from your VS Project to AutoCAD Application context.

这篇关于使用 Autodesk 库中的数据类型后,C# 中的控制台应用程序无法立即执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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