1
votes

I'm using PostSharp to capture all exceptions generated in my system with a class OnMethodBoundaryAspect. It works fine, but if I need to get exceptions in some classes inherited, I can't find solutions to this in VB.NET.

The class MulticastAttributeUsageAttribute has a constructor with one validOn attribute, and I only can set the MultcastTargets. The class has a public property named Inheritance, but if I set this in the constructor, it has no effect. Here follows an example: the class B extends class A, and the attribute aspect is annotated in class A, and I need that class B be automatically seen by the aspect.

How do I solve this problem?

Code

<Serializable()> _
<AttributeUsage(AttributeTargets.Class)> _
<MulticastAttributeUsage(MulticastTargets.Method)> _
Public Class ExceptionsAttribute
    Inherits OnMethodBoundaryAspect

        Public Overrides Sub OnEntry(ByVal Args As PostSharp.Aspects.MethodExecutionArgs)
             MyBase.OnEntry(Args)
        End Sub

        Public Overrides Sub OnException(ByVal Args As PostSharp.Aspects.MethodExecutionArgs)
             MyBase.OnException(Args)
        End Sub

    End Class

    <Exceptions()> _
    Public Class A

        Public Sub MethodA()
        End Sub

    End Class

    Public Class B
        Inherits A

        Public Sub MethodB()
        End Sub

    End Class

Class A is annotated by Exception attribute class. Class B extends class A, then, I need that class B automatically be viewed without need to annotate with the Exception attribute class.

1

1 Answers

1
votes

Solved!!! I need just need to set the attribute directly like:

<MulticastAttributeUsage(MulticastTargets.Method, Inheritance:=MulticastInheritance.Multicast)>