Wcf PostSharp-运营合同中的方法边界方面
我正在运营合同中使用PostSharp-OnMethodBoundaryAspect。不过,这一方面似乎并不火爆。我有必要参考postsharp dll。下面是伪代码Wcf PostSharp-运营合同中的方法边界方面,wcf,aop,postsharp,Wcf,Aop,Postsharp,我正在运营合同中使用PostSharp-OnMethodBoundaryAspect。不过,这一方面似乎并不火爆。我有必要参考postsharp dll。下面是伪代码 面貌 [Serializable] [MulticastAttributeUsage(MulticastTargets.Method, Inheritance = MulticastInheritance.Multicast)] public class LoggingAspect : OnMethodBoundaryAspe
- 面貌
[Serializable] [MulticastAttributeUsage(MulticastTargets.Method, Inheritance = MulticastInheritance.Multicast)] public class LoggingAspect : OnMethodBoundaryAspect { //Implementation for entry and exit }
- 用法
[ServiceContract] public interface ITest { [OperationContract] [LoggingAspect(.....)] void Test(); }
非常感谢您的帮助我们需要做以下工作
感谢AlexD和Daniel Balas的输入添加对PostSharp.dll的引用是不够的,PostSharp需要将自身安装到构建过程中。在*.csproj文件中是否也导入了PostSharp.targets?构建日志中是否有消息表明已调用PostSharp?最后,如果在实现类而不是接口中应用方面,会发生什么?我在.csproj中没有PostSharp.targets。我在一个测试项目中安装了Through nuget。在我的主要项目中;我只是在引用postsharp dll。应该如何包含目标?如果您已将PostSharp软件包添加到项目中,它应该自动添加目标。请注意,您还需要将此包添加到包含此接口实现的项目中(以便PostSharp可以处理这些项目)。是的,我并没有将其添加为对包含此接口的项目的引用。目标不见了。但现在我已经纠正了它。谢谢Alex和Daniel