Your error message shows that the SecurityException
originates from BinaryAspectSerializer
. This is the default class that is used to serialize aspects, which you mark with [Serializable]
attribute.
The best solution here is to contact your hosting provider regarding this problem, as was mentioned already.
As a workaround you may try to use another serializer for your aspect.
If you apply [PSerializable]
attribute to your aspect instead, then the PortableFormatter
is used and it doesn't require full trust.
[PSerializable]
public class LoggingAspect : OnMethodBoundaryAspect
You can also avoid serialization altogether, but that means not using CompileTimeInitialize
method and doing all the aspect initialization during application run-time, possibly losing some performance.
In this case you should use MsilAspectSerializer
and initialize your aspect in its RuntimeInitialize
method. This is documented here: Aspect Serialization
[OnMethodBoundaryAspectConfiguration(SerializerType=typeof(MsilAspectSerializer))]
public class LoggingAspect : OnMethodBoundaryAspect