.NET

Reply
Distinguished Contributor
junoj
Posts: 116
Registered: ‎02-26-2009
Message 1 of 3 (126 Views)

CommandMethod executes command only once ?

126 Views, 2 Replies
09-11-2013 03:22 PM

I am having a very interesting problem with my code. When I run my code the first time CommandMethod works and executes without any problems, When I try to run it again I get : Unknown command. I have to reopen AutoCAD in order to run the command again.

 

Has anyone experience this problem before.

Distinguished Contributor
junoj
Posts: 116
Registered: ‎02-26-2009
Message 2 of 3 (123 Views)

Re: CommandMethod executes command only once ?

09-11-2013 03:58 PM in reply to: junoj

I just ran some test and I got strange but consistent results. When I run the code on AutoCAD 2008 the command run only once, but when I run it on AutoCAD 2010 it works without any problems.

 

It is really strange that the same code runs in 2010 without any problems and in 2008 it is only willing to run once.

Distinguished Contributor
junoj
Posts: 116
Registered: ‎02-26-2009
Message 3 of 3 (102 Views)

Re: CommandMethod executes command only once ?

09-11-2013 11:19 PM in reply to: junoj

Hi everyone, I was able to narrow the problem to ‘System.IO.StreamReader

 

At the start of my code I read a large data file (9000 lines) in with this code:

 

 

Public Class Test
    <CommandMethod("ttt", CommandFlags.Modal)> _
    Public Sub Test()

        Dim objReader As New System.IO.StreamReader("C:\Test.txt")

        Do
            sLine = objReader.ReadLine()
            If Not sLine Is Nothing Then
                Debug.Print(sLine)
            End If
        Loop Until sLine Is Nothing

        objReader.Close()
    End Sub
End Class

 

After reading in the file in, when I try to read the file again I get an ‘Unknown command’. I wonder if the problem is with the buffer . . . . . .

 

Or perhaps there is a workaround this issue.

 

Thank you,

 

-J

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!