PostSharp OnMethodBoundaryAspect OnEntry 未执行
我正在运行 .NET 4.0 Web 应用程序(不是网站)和 PostSharp 1.5。我无法使用 OnMethodBoundaryAspect 基类执行 OnEntry 重写方法。这是一些相关代码:
public sealed class MonitorAttribute : OnMethodBoundaryAspect {
public string[] SomeValue { get; protected set; }
public MonitorAttribute (params string[] someValue){
SomeValue = someValue;
}
public override void OnEntry(MethodExecutionEventArgs eventArgs){
// do Something here
base.OnEntry(eventArgs);
}
}
public sealed class MyUsageClass : IMyUsageClass {
[Monitor(new string[]{ 'Test' })
public void SomeMethod {
// Do something else in here
}
}
我错过了什么吗?它永远不会命中 OnEntry 方法。我还尝试用新的 2.0 版本替换我的 PostSharp.dll 和 PostSharp.Laos.dll 依赖项。如果有什么区别的话,MyUsageClass
由 StructureMap 实例化。
I am running a .NET 4.0 Web Application (not web site) and PostSharp 1.5. I cannot get the OnEntry override method to execute using the OnMethodBoundaryAspect base class. Here is some relevant code:
public sealed class MonitorAttribute : OnMethodBoundaryAspect {
public string[] SomeValue { get; protected set; }
public MonitorAttribute (params string[] someValue){
SomeValue = someValue;
}
public override void OnEntry(MethodExecutionEventArgs eventArgs){
// do Something here
base.OnEntry(eventArgs);
}
}
public sealed class MyUsageClass : IMyUsageClass {
[Monitor(new string[]{ 'Test' })
public void SomeMethod {
// Do something else in here
}
}
Am I missing something? It never hits the OnEntry method. I also tried replacing my PostSharp.dll and PostSharp.Laos.dll dependencies with the new 2.0 version. If it makes any difference MyUsageClass
is instantiated by StructureMap.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,每个开发人员都需要安装 PostSharp。如果您只是使用入门版,那么一切都是免费的。
将此作为答案发布以向您展示代码。我的测试代码
编译后的代码
Yes, every dev will need to have PostSharp installed. If you're just using the starter edition then it's all free.
Posting this as an answer to show you the code. My test code
The code after compilation