.NET

.NET

Reply
Mentor
GeeHaa
Posts: 156
Registered: ‎04-14-2005
Message 1 of 8 (428 Views)
Accepted Solution

Adding a document to documentmanager collection

428 Views, 7 Replies
07-30-2013 10:31 AM

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

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

Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 2 of 8 (419 Views)

Re: Adding a document to documentmanager collection

07-30-2013 11:11 AM in reply to: GeeHaa

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

Mentor
GeeHaa
Posts: 156
Registered: ‎04-14-2005
Message 3 of 8 (414 Views)

Re: Adding a document to documentmanager collection

07-30-2013 11:29 AM 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

Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 4 of 8 (386 Views)

Re: Adding a document to documentmanager collection

07-31-2013 03:56 AM 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.

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 5 of 8 (367 Views)

Re: Adding a document to documentmanager collection

07-31-2013 11:45 AM in reply to: GeeHaa
Try add to Reference: accoremgd.dll
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Mentor
GeeHaa
Posts: 156
Registered: ‎04-14-2005
Message 6 of 8 (357 Views)

Re: Adding a document to documentmanager collection

07-31-2013 12:41 PM 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

Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 7 of 8 (347 Views)

Re: Adding a document to documentmanager collection

07-31-2013 01:49 PM 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.

Mentor
GeeHaa
Posts: 156
Registered: ‎04-14-2005
Message 8 of 8 (341 Views)

Re: Adding a document to documentmanager collection

07-31-2013 01:57 PM in reply to: sszabo

I'm Sorry I meant AcadDoc.lsp file.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.