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

Adding a document to documentmanager collection

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
GeeHaa
970 Views, 7 Replies

Adding a document to documentmanager collection

Hi,

 

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.GetSystemVariable("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

7 REPLIES 7
Message 2 of 8
sszabo
in reply to: GeeHaa

try this: acDoc = DocumentCollectionExtension.Add(acDocMgr, "acad.dwt")instead.

Message 3 of 8
GeeHaa
in reply to: GeeHaa

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

Message 4 of 8
sszabo
in reply to: GeeHaa

It sounds like a multi threading issue but without the whole project attached I can't tell what's going on, sorry.

Message 5 of 8
Hallex
in reply to: GeeHaa

Try add to Reference: accoremgd.dll
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 6 of 8
GeeHaa
in reply to: Hallex

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.

 

Thanks Again

Message 7 of 8
sszabo
in reply to: GeeHaa

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.

Message 8 of 8
GeeHaa
in reply to: sszabo

I'm Sorry I meant AcadDoc.lsp file.

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