.NET

Reply
Active Contributor
patrick.fillion
Posts: 32
Registered: ‎12-18-2006
Message 1 of 5 (284 Views)

Command not starting in debug

284 Views, 4 Replies
10-15-2012 11:03 AM

I am writing a program in vb.net.

I have a command.

<CommandMethod("att2att")> _
    Public Sub att2att()
        Dim ed As Editor
        ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
        ed.WriteMessage(String.Format("{0} commande: att2att, maintenant disponible...", System.Environment.NewLine))
        Dim start As New FileSelect
        start.ShowDialog()

    End Sub

 

In the debug mode, the att2att is not recognize.

If I compile, netload and call the command, it works. Why is the command not recognize in debug mode?

*Expert Elite*
_gile
Posts: 2,106
Registered: ‎04-29-2006
Message 2 of 5 (258 Views)

Re : Command not starting in debug

10-16-2012 01:00 AM in reply to: patrick.fillion

Salut,

 

Si ça fonctionne avec NETLOAD c'est probablement que le problème ne vient pas du code mais de ce qui est automatiquement exécuté au lancement du débogage.

Si rien n'a été explicitement fait pour que la dll soit chargée au démarrage d'AutoCAD (un script par exemple), elle ne sera pas automatiquement chargée (c'est le cas avec les AutoCAD .NET Wizards).

 

Tu trouveras sur Augifr un tuto pour créer des modèles AutoCAD pour Visual Studio avec une méthode de chargement automatique de la dll via un script :

http://augifr.ning.com/group/augi-france-developer-network-afdn/page/bibliotheque-afdn#.UH0UElHYf3Q

Gilles Chanteau
*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 3 of 5 (247 Views)

Re: Command not starting in debug

10-16-2012 03:51 AM in reply to: patrick.fillion

Try compile your project as follows:

 #region "Imports"
'' your imports here

#End Region

 <Assembly: Autodesk.AutoCAD.Runtime.CommandClass(GetType(MyProjectName.MyClass))> 

Namespace MyProjectName

    Public Class MyClass

        <CommandMethod("att2att")> _
        Public Sub att2att()
' wrap your code in try-catch block
Try
            Dim ed As Editor
            ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
            ed.WriteMessage(String.Format("{0} commande: att2att, maintenant disponible...", System.Environment.NewLine))
            Dim start As New FileSelect
            start.ShowDialog()
Catch ex as System.Exception
Msgbox(ex.message & vblf & ex.stacktrace)
Finally
' do nothing or add informative message
end Try

End Sub

end class

End Namespace

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Active Contributor
patrick.fillion
Posts: 32
Registered: ‎12-18-2006
Message 4 of 5 (244 Views)

Re: Command not starting in debug

10-16-2012 05:36 AM in reply to: patrick.fillion

Well, the problem is that in the debug, I do the netload but the att2att commande doesn't show. If I compile then run autocad and then netload the same dll, the att2att command is available...

 

I really wish I could use the debugger... it will save me so much time. Thanks all for the help!

 

That is kind of strange! I change my code as:

 

#Region " Imports "

Imports System.IO
Imports Autodesk.AutoCAD.Interop

Imports System.Runtime.InteropServices
Imports System.Windows.Forms
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
'Imports Autodesk.AutoCAD.PlottingServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
#End Region

 

<Assembly: Autodesk.AutoCAD.Runtime.CommandClass(GetType(UpdCart.commandes))>

Namespace UpdCart


    Public Class Commandes


        <CommandMethod("att2att")> _
        Public Sub att2att()



            Try
                Dim ed As Editor
                ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
                ed.WriteMessage(String.Format("{0} commande: att2att, maintenant disponible...", System.Environment.NewLine))
                Dim start As New FileSelect
                start.ShowDialog()

            Catch ex As System.Exception
                MessageBox.Show(ex.ToString, "System Exception")

            End Try



        End Sub

    End Class

End Namespace

ADN Support Specialist
Balaji_Ram
Posts: 715
Registered: ‎03-21-2011
Message 5 of 5 (188 Views)

Re: Command not starting in debug

10-23-2012 10:29 AM in reply to: patrick.fillion

Hello Patrick,

 

Are you referring to debugging by attaching to an running instance of AutoCAD to debug the .Net Plug-in ?

 

If so, “Attach to Process” for debugging a .Net plugin is not recommended and the suggested way to debug a .Net plugin is to set AutoCAD as the external program and use F5.

 

The reason for it is due to the use of fibers in AutoCAD which is being removed in the newer releases of AutoCAD.

Hopefully this will not be a limitation in a future release of AutoCAD.

 

You may try "Attach to Process" after setting the "NEXTFIBERWORLD" to 0 to disable the fibers in AutoCAD but it has some drawbacks such as the ribbon not responding. I havent tried this though.

 

 

 

 

 



Balaji
Developer Technical Services
Autodesk Developer Network

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.