Erwin Mayer
Erwin Mayer

Reputation: 18670

AccessViolationException not caught despite HandleProcessCorruptedStateExceptions

I am puzzled. An AccessViolationException is randomly raised by a third-party library. It can safely be ignored, so I am wrapping the calling method in a [HandleProcessCorruptedStateExceptions] attribute as suggested here.

However, I am still seeing the exception getting raised as visible below: enter image description here

I am using .NET Framework 4.6.2 and Visual Studio 2015 Update 3. What could I have missed?

Upvotes: 1

Views: 1311

Answers (1)

haindl
haindl

Reputation: 3221

You forgot to insert a try/catch around table.Start().

[HandleProcessCorruptedStateExceptions] definitely needs a try/catch to catch that AccessViolationException.

So your code should be:

[HandleProcessCorruptedStateExceptions]
private static void StartTable(Table table) {
    try
    {
        table.Start();
    }
    catch (AccessViolationException)
    {
        // Ignore
    }
}

You can take a look at here or here for references.

Upvotes: 1

Related Questions