.NET

Reply
Mentor
matus.brlit
Posts: 246
Registered: ‎03-11-2008
Message 1 of 6 (1,725 Views)
Accepted Solution

1073741819 (0xc0000005) 'Access violation'.

1725 Views, 5 Replies
06-28-2013 04:33 AM

The program '[6352] acad.exe: Managed (v4.0.30319)' has exited with code -1073741819 (0xc0000005) 'Access violation'.

 

This is the last line from the output window. Before that, i have couple of warning about dispose call and first chance exceptions:

 

A first chance exception of type 'Autodesk.AutoCAD.Runtime.Exception' occurred in AcdbMgd.dll
A first chance exception of type 'Autodesk.AutoCAD.Runtime.Exception' occurred in AcdbMgd.dll
Forgot to call Dispose? (Autodesk.AutoCAD.DatabaseServices.BlockTableRecord): DisposableWrapper
Forgot to call Dispose? (Autodesk.AutoCAD.DatabaseServices.BlockTableRecord): DisposableWrapper

 

I have chacked all exceptions in the debug settings, but still no exception is thrown and autocad just falls down.

 

Any idea, how to catch this exception?

 

Thanks

Just a guess, but this 'Looks' like the clasic .NET Dispose issue. You must Dispose of AutoCAD referanced objects explicetly. AutoCAD runs on a single thred; The .NET Garbage collector can call .Dispose from another thread, which is bad. Make sure you use 'Using' (For VB) the vars, or that you call dispose of them with a direct call of Dispose. This is usually a 'random'ish crash, can you reproduce it?

 

HomeBoy Out

Valued Contributor
sszabo
Posts: 86
Registered: ‎09-05-2012
Message 2 of 6 (1,714 Views)

Re: 1073741819 (0xc0000005) 'Access violation'.

06-28-2013 06:07 AM in reply to: matus.brlit

Your plugin runs in the same .NET AppDomain as Autocad so theoretically you should be able to catch all uncaught exceptions in an IExtensionApplication as such:

 

Public Sub Initialize() Implements _
        Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
            AddHandler AppDomain.CurrentDomain.FirstChanceException, AddressOf GlobalExHappened
            AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExHappened
 End Sub

 

    Public Sub GlobalExHappened(source As Object, e As FirstChanceExceptionEventArgs)
        log.FatalException(e.Exception)
    End Sub

    Public Sub UnhandledExHappened(source As Object, e As UnhandledExceptionEventArgs)
        log.FatalException(e)
    End Sub

Active Contributor
HomeBoyLV
Posts: 47
Registered: ‎06-04-2004
Message 3 of 6 (1,685 Views)

Re: 1073741819 (0xc0000005) 'Access violation'.

06-28-2013 05:52 PM in reply to: matus.brlit

Just a guess, but this 'Looks' like the clasic .NET Dispose issue. You must Dispose of AutoCAD referanced objects explicetly. AutoCAD runs on a single thred; The .NET Garbage collector can call .Dispose from another thread, which is bad. Make sure you use 'Using' (For VB) the vars, or that you call dispose of them with a direct call of Dispose. This is usually a 'random'ish crash, can you reproduce it?

 

HomeBoy Out

Active Contributor
HomeBoyLV
Posts: 47
Registered: ‎06-04-2004
Message 4 of 6 (1,684 Views)

Re: 1073741819 (0xc0000005) 'Access violation'.

06-28-2013 05:54 PM in reply to: sszabo

sszabo wrote:

Your plugin runs in the same .NET AppDomain as Autocad so theoretically you should be able to catch all uncaught exceptions in an IExtensionApplication as such:

 

Public Sub Initialize() Implements _
        Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
            AddHandler AppDomain.CurrentDomain.FirstChanceException, AddressOf GlobalExHappened
            AddHandler AppDomain.CurrentDomain.UnhandledException, AddressOf UnhandledExHappened
 End Sub

 

    Public Sub GlobalExHappened(source As Object, e As FirstChanceExceptionEventArgs)
        log.FatalException(e.Exception)
    End Sub

    Public Sub UnhandledExHappened(source As Object, e As UnhandledExceptionEventArgs)
        log.FatalException(e)
    End Sub


Cool, I did'nt know that! Thanks

 

HomeBoy Out

Mentor
matus.brlit
Posts: 246
Registered: ‎03-11-2008
Message 5 of 6 (1,646 Views)

Re: 1073741819 (0xc0000005) 'Access violation'.

06-30-2013 11:34 PM in reply to: sszabo
thanks, cool tip
Mentor
matus.brlit
Posts: 246
Registered: ‎03-11-2008
Message 6 of 6 (1,644 Views)

Re: 1073741819 (0xc0000005) 'Access violation'.

06-30-2013 11:41 PM in reply to: HomeBoyLV

thanks HomeBoy, you were right,

I found the cause after i read Kean's blog here: http://through-the-interface.typepad.com/through_the_interface/2008/06/cleaning-up-aft.html

 

I created a BlockTableRecord object, that I meant to use later, but not in all branches, so sometimes, it was not added to transaction and then AutoCAD crashed, when I closed the window. That's why it was hard to reproduce, because it didn't crash after the action, but when the garbage collector came in action, which was not after each close.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!