Hi,
I have made a .NET exe, that communicates with AutoCAD.
As AutoDesk exchange requires dll, I built the Visual Studio solution with application type Class Library. The output DLL was used in .bundle.
But, although, the command is loaded (in autosuggestions), AutoCAd returns "Unknown Command".
Can anyone help why does this happen?
[Instead of .dll, a .lsp works. So I doubt the problem is with my converting exe to dll. I am not with a formal programming background]
Thanks in advance
MdShameer
Solved! Go to Solution.
Solved by Buzz0m. Go to Solution.
Hi,
When you migrate something from EXE to DLL for AutoCAD, you need to make adjustments so AutoCAD will recognize the commands.
For instance, all methods that a user can call must have a CommandMethod attribute. This is done with some additional references, not available on EXE: AcMgd, AcDbMgd and AcCoreMgd (this last for 2013+)
Not sure how far you are on the migration, let us know...
I do not exactly recall how I overcame this problem. But, looking back at the VS project files, I think you can check the following:
Regards
Shameer
Hi @mdshameer,
moments after I posted I figured out I need to do something like that 😃
If I understood correctly, you have one .dll file ("startup.dll") which contains the commandmethod. This method references the original ".exe"-code ("program.dll"), which has been built into a .dll-file? So in autocad you pass the command to startup.dll (using the PackageContents.xml) which in turn tells program.dll to run...?
In my case I have winform program in c# which works fine by itself. I'd like to publish it in autodesk exchange and need to make it work via AutoCAD. Do you think I'm on the right track or do I need to know something more?
- F
Here's the code that I used (in case somebody else needs an example). My build was for Acad 2017... don't know too much about the namespaces (some or most of the ones listed below might be redundant) but they were referenced when I used the acad template so I left them as they were...
using System; using System.IO; using System.Reflection; using System.Diagnostics; using Autodesk.AutoCAD.Runtime; using Autodesk.AutoCAD.ApplicationServices; using Autodesk.AutoCAD.DatabaseServices; using Autodesk.AutoCAD.Geometry; using Autodesk.AutoCAD.EditorInput; // This line is not mandatory, but improves loading performances [assembly: CommandClass(typeof(C2A_startup.MyCommands))] namespace C2A_startup { public class MyCommands { [CommandMethod("C2A", CommandFlags.Modal)] public void myAppStartup() //This method starts the myApp.exe { Assembly currentAssem = Assembly.GetExecutingAssembly(); string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); Process myProcess = new Process(); myProcess.StartInfo.FileName = assemblyFolder+ "\\myApp.exe"; myProcess.Start(); } } }
- F