The code below crashes with an "attempt to write to protected memory" in debug mode (it crashes when it hits acDocMgr.add)but in the Release version it works fine. Should I be worried? I am using Command Flags.Session
Dim acDocMgr As DocumentCollection = Application.DocumentManager Dim pStyle As Integer = Autodesk.AutoCAD.ApplicationServices.Application.G
etSystemVariable("PSTYLEMODE") Dim acDoc As Document = Nothing If pStyle = 1 Then acDoc = acDocMgr.Add("acad.dwt") Else acDoc = acDocMgr.Add("acad -Named Plot Styles.dwt") End If
Thanks in Advance
Solved! Go to Solution.
Thanks for the reply,
I tried using the documentcollectionextension but it still has the same error.
this appears in the imediate window
A first chance exception of type 'Autodesk.AutoCAD.Runtime.Exception' occurred in AcdbMgd.dll
Nevermind I figured it out. I have a startup sequence in my ACAD.Doc file that makes a call to VBA to pop up a messagebox if the filename doesn't match the drawing number. I disabled it and it runs fine now in debug mode. I'm still wondering why the release version ran fine though.
In debug mode you are running under msvsmon and your VBA code is running under acad. You would probably have to use InvokeRequired around your Document object for this to work, again just guessing here.