Exception Behavior in C # 2 Delegates Hosted in MS Excel and COM

Morning everything

A bat language theory question is here ... I found some links on the Internet suggesting that exception handling and delegate in C # have different behavior in some cases, but I can not find any specific documentation on this.

Recently, we had some big problems with exceptions inside delegates for adding Microsoft Excel, which caused a serious error in the MSVC runtime. Removing delegates allowed this, but now I'm curious to know the details.

As a short example of kernel code:

Delegate del; // initialized elsewhere
try
{
    del.DynamicInvoke();
}
catch(Exception e)
{
    /* Parsing of exception to generate user-friendly message here */
}

. ​​ .

, (, "" ToString() ) , , .

MS Excel . , , , , .

, COM, .NET(, , ), - .NET. Excel , COM - Excel .

Excel + COM +, , ... ?

+3
4

, , COM MS Excel, , . MS Office , ( Outlook).

COM , . , Application.ThreadException( WinForms) AppDomain.CurrentDomain.UnhandledException.

, Marshal.ReleaseComObject() , , {} , , Excel , .

+1

: , "" , , , , .

try/catch , (, , ), / .

, COM- Excel, .

:

  • ?
  • , , Excel?
  • , ( ApplicationException();) , ?

0

- !

- "" , , , , .

, , . , , , , , , , , , .

?

, .NET, #/. NET

, (throw new ApplicationException();) , ?

, , . , , - .

COM- MS Excel, ,

. VBA Excel COM .NET, - .

, Application.ThreadException( WinForms) AppDomain.CurrentDomain.UnhandledException.

, . , AppDomain, , - .

Marshal.ReleaseComObject()

, . - COM (!), .NET CLR ...

, , . , ( ) Office + VBA + COM + CLR-: -)

0

, , , , . , async, , async invoke.

0

Source: https://habr.com/ru/post/1698396/


All Articles