.NET

Reply

obtaining audit results in .net

313 Views, 12 Replies
04-20-2006 02:48 PM
When using the function "ReadDwgFile" to populate
a new database from a drawing on file, if there are
any problems with the drawing being read the "ReadDwgFile"
will terminate without any error.
I found this out the hard way by stepping though some code
over and over trying to figure out why I was only finding
2 enities in a database when I knew there were far more.
I discovered the problem when I simply opened the drawing in
Acad and found that it required "recovery".
So my question is: when utilizing "ReadDwgFile" how can one
tell if there were any audit problems during the read so you
can pop up a warning to the user to recover the drawing first?
Thanks, Perry

Re: obtaining audit results in .net

04-20-2006 03:42 PM in reply to: *perry
One other thing. I found that when iterating through
a directory of drawings and opening each for read
I had to call dispose() on each iteration or nasty
things would happen. In every other example I have seen
so far, dispose was NOT called, the routines would
rely solely on disposing the transaction.
Is there something wrong with my routine, or should
I be disposing the databases if opening one after another?
*Tony Tanzillo
Post 3 of 13

Re: obtaining audit results in .net

04-20-2006 09:15 PM in reply to: *perry
>> Is there something wrong with my routine, or should
>> I be disposing the databases if opening one after another?

Yes, you must call Dispose() on a Database when you're
done with it.

Remember that it is a wrapper for an AcDbDatabase*, which
you would always delete the pointer to (in unmanaged ARX)
when you're done with it (right?). So how else would the
Database wrapper know if/when it should do that if you don't
tell it (by calling Dispose) ?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

"perry" wrote in message news:5149678@discussion.autodesk.com...
One other thing. I found that when iterating through
a directory of drawings and opening each for read
I had to call dispose() on each iteration or nasty
things would happen. In every other example I have seen
so far, dispose was NOT called, the routines would
rely solely on disposing the transaction.

Re: obtaining audit results in .net

04-21-2006 08:08 AM in reply to: *perry
Tony Tanzillo wrote:
> Yes, you must call Dispose() on a Database when you're
> done with it.
>
> Remember that it is a wrapper for an AcDbDatabase*, which
> you would always delete the pointer to (in unmanaged ARX)
> when you're done with it (right?). So how else would the
> Database wrapper know if/when it should do that if you don't
> tell it (by calling Dispose) ?
>
True Tony, I remember from doing C++/Arx that you MUST call
delete() or face headaches. But being a C# newbie I was lead
to believe that we now rely on "garbage collection" for this.
Also, virtually all of the samples in th SDK, none of them
call dispose on the database. They do call dispose on the
transaction (this disposes the database too?) Bad examples??
In my function I had to call dispose on both the transaction
and the database. Perhaph because the database was created
outside the try block?
Im thinking maybe I should start using the "using" statement
for this and forget try/catch/finally/dispose altogether.

Thanks for the input, Perry
*J. Daniel Smith
Post 5 of 13

Re: obtaining audit results in .net

04-21-2006 10:16 AM in reply to: *perry
Using "using" is generally preferred over try/catch/finally--if your only
reason for finally is to call Dispose().

Dan

"perry" wrote in message
news:5150338@discussion.autodesk.com...
Tony Tanzillo wrote:
> Yes, you must call Dispose() on a Database when you're
> done with it.
>
> Remember that it is a wrapper for an AcDbDatabase*, which
> you would always delete the pointer to (in unmanaged ARX)
> when you're done with it (right?). So how else would the
> Database wrapper know if/when it should do that if you don't
> tell it (by calling Dispose) ?
>
True Tony, I remember from doing C++/Arx that you MUST call
delete() or face headaches. But being a C# newbie I was lead
to believe that we now rely on "garbage collection" for this.
Also, virtually all of the samples in th SDK, none of them
call dispose on the database. They do call dispose on the
transaction (this disposes the database too?) Bad examples??
In my function I had to call dispose on both the transaction
and the database. Perhaph because the database was created
outside the try block?
Im thinking maybe I should start using the "using" statement
for this and forget try/catch/finally/dispose altogether.

Thanks for the input, Perry

Re: obtaining audit results in .net

04-22-2006 08:00 PM in reply to: *perry
Any comments on the Audit issue?
New Member
1 Posts
0 Kudos
Registered: ‎11-29-2005
Post 7 of 13

Re: obtaining audit results in .net

12-08-2006 08:05 PM in reply to: *perry
Did you ever find the answer to your Audit question.
New Member
2 Posts
0 Kudos
Registered: ‎10-30-2008
Post 8 of 13

Re: obtaining audit results in .net

12-06-2008 04:22 PM in reply to: *perry
was this ever resolved?

running into the same problem.
Mentor
188 Posts
11 Kudos
Registered: ‎01-06-2003
Post 9 of 13

Re: obtaining audit results in .net

04-07-2012 11:49 PM in reply to: *perry

Any development on Audit via .NET? Regards, Dale

Mentor
188 Posts
11 Kudos
Registered: ‎01-06-2003
Post 10 of 13

Re: obtaining audit results in .net

11-04-2012 01:31 AM in reply to: *perry

Any takers on Audit? Dale

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!