The problem:
When calling extern method, it may throw System.AccessViolationException, which can not be catched and will crashes the process.
To catch this exception (.NET Framework only), the caller must set two attributes on current method: HandleProcessCorruptedStateExceptionsAttribute and SecurityCriticalAttribute.
But the weaver did not copy these attributes to the generated innner method, and causes the process crash.
Possible solution
- Always copy these two attributes to inner method if exist
This is the easist but not the best, because it takes extra steps to check attributes.
- Allow set custom attributes in user advices.
Users can set attributes based on their logic.