Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wcf PostSharp-运营合同中的方法边界方面_Wcf_Aop_Postsharp - Fatal编程技术网

Wcf PostSharp-运营合同中的方法边界方面

Wcf PostSharp-运营合同中的方法边界方面,wcf,aop,postsharp,Wcf,Aop,Postsharp,我正在运营合同中使用PostSharp-OnMethodBoundaryAspect。不过,这一方面似乎并不火爆。我有必要参考postsharp dll。下面是伪代码 面貌 [Serializable] [MulticastAttributeUsage(MulticastTargets.Method, Inheritance = MulticastInheritance.Multicast)] public class LoggingAspect : OnMethodBoundaryAspe

我正在运营合同中使用PostSharp-OnMethodBoundaryAspect。不过,这一方面似乎并不火爆。我有必要参考postsharp dll。下面是伪代码

  • 面貌

    [Serializable]
    [MulticastAttributeUsage(MulticastTargets.Method, Inheritance =  MulticastInheritance.Multicast)]
    public class LoggingAspect : OnMethodBoundaryAspect
    {
      //Implementation for entry and exit
    }
    
  • 用法

    [ServiceContract]
    public interface ITest
    {
     [OperationContract]
     [LoggingAspect(.....)]
      void Test();
    }
    

非常感谢您的帮助

我们需要做以下工作

  • 通过NuGet在要编写自定义特性的项目上安装Postsharp
  • 这将确保目标存在于.csproj文件中,从而在编译时启用注入
  • 在您希望使用您在#1中编写的方面的所有项目中安装PostSharp Through NuGet

  • 感谢AlexD和Daniel Balas的输入

    添加对PostSharp.dll的引用是不够的,PostSharp需要将自身安装到构建过程中。在*.csproj文件中是否也导入了PostSharp.targets?构建日志中是否有消息表明已调用PostSharp?最后,如果在实现类而不是接口中应用方面,会发生什么?我在.csproj中没有PostSharp.targets。我在一个测试项目中安装了Through nuget。在我的主要项目中;我只是在引用postsharp dll。应该如何包含目标?如果您已将PostSharp软件包添加到项目中,它应该自动添加目标。请注意,您还需要将此包添加到包含此接口实现的项目中(以便PostSharp可以处理这些项目)。是的,我并没有将其添加为对包含此接口的项目的引用。目标不见了。但现在我已经纠正了它。谢谢Alex和Daniel