如何提高.NET插件开发的速度? [英] How can I improve the speed of .NET Plug-in Development?

查看:112
本文介绍了如何提高.NET插件开发的速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个AutoCAD加载项,它使用.NET 4.6程序集.我发现开发过程非常令人沮丧; API很大,除入门外的文档无处不在,很难找到.完成任何事情的唯一方法似乎只是在Visual Studio中对函数进行原型设计,并查看其是否有效.然后,需要几分钟来加载AutoCAD并附加一个调试器,这使我的原型工作流程不堪重负.

I'm developing an AutoCAD add-in, which uses a .NET 4.6 assembly. I am finding the development process very frustrating; the API is very large and the documentation beyond getting started is all over the place and very hard to find. The only way to get anything done seems to be just prototyping functions in Visual Studio and seeing if it works. It then takes several minutes to load up AutoCAD and attach a debugger, which wrecks my prototyping workflow.

如果我可以使用Linqpad之类的应用程序来原型化我的应用程序,以便可以找到所需的数据,那将非常方便.我不喜欢使用Linqpad的想法;但是,如果我想念另一种技术,我很想听听.

It would be very handy if I could have something like Linqpad to prototype my applications so I can find the data that I'm looking for. I'm not married to the idea of using Linqpad; however, if there's another technique I'm missing I'd love to hear about it.

我不确定使用专业版是否可以实现此目的,但是由于没有试用版,所以无法找到.

I'm not sure if this is something I might achieve with the pro version but as there is no trial I can't find out.

推荐答案

是的,API确实很大,并且某些功能的文档记录很少.我发现很难上手,但是一旦我熟悉了核心概念和功能,我就开始非常喜欢使用它,因为一旦获得它",API便非常强大且易于使用.我不确定您检查了哪些资源,但我先从此开发人员文档.向下滚动到培训实验室.我建议您至少通读ObjectARX和.NET培训实验室.花几天时间在.NET实验室中工作,因为它将为您节省大量的时间.

It is true, the API is indeed large, and some functionality is somewhat poorly documented. I found it difficult to get started, but once I became familiar with the core concept and functionality, I started to very much enjoy working with it as the API very powerful and easy to work with once you "get it". I am not sure what sources you have checked, but I started with this Developer Documentation. Scroll down to the training labs. I would recommend that you at least read through both ObjectARX and .NET Training labs. Spend a few days working through the .NET labs as it will save you countless hours down the line.

对于调试,下面的设置应为您提供最有效的方法(此处我使用VS 2015和AutoCad 2015).在项目属性的调试"选项卡下,您的设置应如下所示:

As for debugging, the set-up below should give you the most effective and efficient approach (here I use VS 2015 and AutoCad 2015). In the project properties, under the "Debug" tab, your settings should be as follows:

  1. 选中启动外部程序:",然后输入AutoCad可执行文件的路径.这适用于其他版本的AutoCad.
  2. 在命令行参数:"字段中,输入/nologo.这将大大加快AutoCad的启动速度.
  1. Check "Start external program:" and enter the path of the AutoCad executable. This applies to other versions of AutoCad.
  2. In the "Command line arguments:" field, enter /nologo. This will significantly speed up the start-up of AutoCad.

要自动将dll加载到AutoCad ,您可以通过注册表(我的首选方式)或通过acad20xxdoc.lsp或acad.lsp(AutoCad将默认为每个脚本运行这些脚本)进行加载您打开的文件或分别启动AutoCad的文件).您可以在

To load your dll into AutoCad automatically, you can either do it through the registry (my preferred way) or through acad20xxdoc.lsp or acad.lsp (AutoCad will run these scripts by default for each document you open or when AutoCad starts respectively). You can find details in this post.

现在按 F5 将启动AutoCad并加载调试器.现在,您可以像其他任何代码段一样单步执行代码行.在代码的开头放置一个断点,然后在AutoCad中执行命令.您的断点应该被击中.

Now Pressing F5 will start AutoCad and load the debugger. You can now step through lines of code as for any other piece of code. Place a break point at the start of your code, then execute your command in AutoCad. Your break point should get hit.

旁边: /nologo也可以添加到AutoCad的桌面快捷方式中,以加快用户使用AutoCad的速度.可以将其添加到快捷方式属性的目标:"字段中.即"C:\Program Files\Autodesk\AutoCAD 2015\acad.exe" /nologo

Aside: /nologo can also be added to AutoCad's Desktop shortcut to speed up AutoCad for users. It can be added to the "Target:" field in the shortcut properties. i.e. "C:\Program Files\Autodesk\AutoCAD 2015\acad.exe" /nologo

注意:可能的陷阱!确保项目引用的所有AutoCad dll的属性都设置为:

Note: A possible Gotcha! Make sure that any AutoCad dlls that your project references have their properties set to:

  1. 嵌入互操作类型->错误
  2. 复制本地->错误.还要确保在Debug/Release目录中没有AutoCAD dll(即acmgd.dll或任何名称以"ac"开头的dll).删除找到的任何内容.不这样做将导致错误和崩溃,很难追踪.
  1. Embed Interop Types -> False
  2. Copy Local -> False. Also make sure that there are no AutoCAD dlls (i.e. acmgd.dll or any dlls with names starting with "ac") in your Debug/Release directory. Delete any that you find. Not doing so will cause errors and crashes that will be very hard to trace down.

这篇关于如何提高.NET插件开发的速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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