ADXExcelRef.ConvertToA1Style

Add-in Express™ Support Service
That's what is more important than anything else

ADXExcelRef.ConvertToA1Style
 
ewessely




Posts: 47
Joined: 2019-01-31
Good morning Andrei,

I also thought about maintaining separate collections and trace renaming and deleting of sheets and workbooks. But that's not really a fancy solution for the simple problem of validating an ADXRef.

When diving deeper and deeper into the "System.AccessViolationException" of "Attempted to read or write protected memory." i found the following in the Framework documentation: Starting with .NET4 AccessViolationExceptions are no longer handled by default by the catch statement. But you can overcome this. In my situation I decorated the function, where I do the validation with the HandleProcessCorruptedStateExceptions Attribute

using System.Runtime.ExceptionServices;

[HandleProcessCorruptedStateExceptions]
internal static bool TestExcelRef(ADXExcelRef aDXExcelRef)
{
    try
    {
        ...
    }
    catch (Exception e)
    {
        ...
    }
}


For me that solution works and seems simple and very fast.

Would be cool, if ADX would catch that error (and maybe potential similar) internally in the ADXExcelRef.ConvertToA1Style() function and throw a "standard" .net exception like "invalid reference".


Many thanks for your help, Andrei, and keep healthy!

br
ERich
ew
Posted 17 Nov, 2020 03:20:58 Top
Andrei Smolin


Add-in Express team


Posts: 17502
Joined: 2006-05-11
Hello Erich,

Intercepting that exception is the responsibility of the developer. I suppose intercepting that exception in the code of Add-in Express may limit the developer too much.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 17 Nov, 2020 04:07:40 Top