문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top