Question

I'm using PostSharp to add an aspect to a WebMethod.

Below is my aspect (it does nothing... doesn't want to compile):

public class MyAspect : OnMethodBoundaryAspect, ISerializable
{
    public override void OnException(MethodExecutionEventArgs eventArgs)
    {

    }

    public override void OnEntry(MethodExecutionEventArgs eventArgs)
    {

    }

    public void GetObjectData(SerializationInfo info, StreamingContext context)
    {

    }
}

And my webmethod looks like :

    [MyAspect]
    [WebMethod]
    public void MyWebMethod()
    {
        //...
    }

When I build the project, there is an error:

Erreur 346 PostSharp: Cannot serialize the aspects: Le type 'xxxx.MyAspect' dans l'assembly 'zzzzz, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' n'est pas marqué comme sérialisable.. unknown_location xxxxx

It tells me that my aspect is not tagged as serializable...

What can I do? FYI, I don't have any problem with such aspects in the rest of the project.

Was it helpful?

Solution

You should add the Serializable attribute to your MyAspect. So:

[Serializable]
public class MyAspect : OnMethodBoundaryAspect

Instead of inheriting the ISerializable interface. For the differences see this question.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top