Message 1 of 3
Not applicable
08-17-2012
05:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I am working on tcp server plugin for ACD. I want that server write in commandline history what's happenning.
When i run plugin followng error ocurs: System Null Reference Exception
That is my code:
Imports System.Net.Sockets
Imports System.Text
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.DatabaseServices
Imports System.Net
Imports System.Threading
Imports Autodesk.AutoCAD.EditorInput
Public Class Commands Dim close As Boolean = True Dim tcpListener As TcpListener Dim tcpClient As TcpClient Dim mThread As Thread <CommandMethod("StartServer")> Public Sub StartServer() Const portNumber As Integer = 8000 Dim ip As IPAddress = IPAddress.Parse("127.0.0.1") tcpListener = New TcpListener(ip, portNumber) mThread = New Thread(AddressOf MainThread) mThread.Start() End Sub Private Sub MainThread() tcpListener.Start() Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor ed.WriteMessage("Waiting for connection...") While (close) Try tcpClient = tcpListener.AcceptTcpClient() ed.WriteMessage("Connection accepted.") If (tcpClient.Connected) Then Dim thread As Thread = New Thread(AddressOf ThreadTask) thread.Start() End If Catch e As Exception End Try End While End Sub End Class
It shows that error happened here:
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Solved! Go to Solution.