.NET

Reply
Distinguished Contributor
GeeHaa
Posts: 146
Registered: ‎04-14-2005
Message 1 of 8 (360 Views)
Accepted Solution

Adding a document to documentmanager collection

360 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

Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 2 of 8 (351 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.

Distinguished Contributor
GeeHaa
Posts: 146
Registered: ‎04-14-2005
Message 3 of 8 (346 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 (318 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 (299 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
Distinguished Contributor
GeeHaa
Posts: 146
Registered: ‎04-14-2005
Message 6 of 8 (289 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 (279 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.

Distinguished Contributor
GeeHaa
Posts: 146
Registered: ‎04-14-2005
Message 8 of 8 (273 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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community