Message 1 of 5
Problem with the Publish command when called within VB.NET.

Not applicable
02-02-2004
02:28 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have noticed a few other postings regarding this problem, however, I have not been able to find a solution yet. When I try running the publish command from within a VB.NET application I get the following FATAL ERROR: Unhandled Access Violation Reading 0x4caf778 Exception at 62d2e8aah.
Here are the lines that cause the problem:
strCommand = "(command " & Chr(34) & "-publish" & Chr(34) & " " & Chr(34) & "C:/temp/A00214.dsd" & Chr(34) & ")" & Chr(13)
objAcadDoc.SendCommand(strCommand)
If I break right before this call and try running the exact same command from the AutoCAD command prompt, everything works fine.
Since I havn't had any luck with the SendCommand method, I'm also trying to implement the WinAPI SendMessage method. If anyone can post an example of how I would implement the SendMessage method from VB.NET it would help a lot.
Here is what I have so far with the SendMessage method. This doesn't error on me, instead nothing happens at all.
_
Public Shared Function SendMessageA(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
End Function
_
Public Shared Function FindWindowA(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
End Function
Public Function SendACADCommand(ByVal strCommand As String, ByVal objAcadDoc As AutoCAD.AcadDocument) As Boolean
'remeber that strCommand = "(command " & Chr(34) & "-publish" & Chr(34) & " " & Chr(34) & "C:/temp/A00214.dsd" & Chr(34) & ")" & Chr(13)
Const WM_COPYDATA = &H4A
Dim Hwnd As Long = FindWindowA(vbNullString, objAcadDoc.Name)
SendMessageA(Hwnd, WM_COPYDATA, Hwnd, strCommand)
End Function
Thanks,
Paul Thompson
Continental Imaging Products
paul.thompson@gocip.com
(403)541-2545