.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Command not starting in debug

4 REPLIES 4
Reply
Message 1 of 5
patrick.fillion
926 Views, 4 Replies

Command not starting in debug

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?

Tags (1)
4 REPLIES 4
Message 2 of 5
_gile
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
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 5
Hallex
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
Message 4 of 5

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

Message 5 of 5

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost