可以在网站项目中使用 postsharp 方面吗? [英] Can postsharp aspects be used on website projects?

查看:25
本文介绍了可以在网站项目中使用 postsharp 方面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 VS2012 的网站项目中使用 PostSharp 方面.当我设置一个 Web 应用程序项目时,它似乎工作正常,但是当我将 aspect 属性应用于网站项目中页面上的方法时,它编译并运行良好,但我的 OnMethodBoundaryAspect 从未被击中.我尝试从方面方法设置断点和日志记录.

I'm trying to use a PostSharp aspect in a website project in VS2012. It seems to work fine when I set up a web application project, but when I apply the aspect attribute to a method on a page in the website project it compiles and runs fine, but my OnMethodBoundaryAspect never gets hit. I tried setting breakpoints and logging from the aspect methods.

PostSharp 是否支持网站项目?如果是这样,我错过了什么?

Does PostSharp support website projects? if so, what am I missing?

请不要评论我为什么要使用网站而不是网络应用程序.不幸的是,这是一项要求(不要问).

Please no comments about why I want to use a website instead of a web app. Unfortunately it is a requirement (don't ask).

这是我的方面代码(全部在 vb.net 中),但就像我说的,它在网络应用项目上运行良好:

This is my aspect code (all in vb.net), but like I said, it works fine on a web app project:

Imports PostSharp.Aspects

Namespace TestAopLib

<Serializable>
Public Class AopTester
    Inherits OnMethodBoundaryAspect

    Public Overrides Sub OnEntry(args As MethodExecutionArgs)
        MyBase.OnEntry(args)
        Debug.WriteLine("In OnEntry")
    End Sub

    Public Overrides Sub OnExit(args As MethodExecutionArgs)
        MyBase.OnExit(args)
        Debug.WriteLine("In OnExit")
    End Sub

    Public Overrides Sub OnSuccess(args As MethodExecutionArgs)
        MyBase.OnSuccess(args)
        Debug.WriteLine("In OnSuccess")
    End Sub

    Public Overrides Sub OnException(args As MethodExecutionArgs)
        MyBase.OnException(args)
        Debug.WriteLine("In OnException")
    End Sub

End Class

End Namespace

推荐答案

有一个开源项目这正是实现了这一点(正如 CodingSource 所提到的).但是,它是为 PostSharp 2.x 完成的,既不推荐也不支持(如项目主页所述).如果没有重大问题,它很可能不适用于 PostSharp 3+.

There is a open-source project that achieves exactly this (as also mentioned by CodingSource). However, it was done for PostSharp 2.x and is neither recommended or supported (as stated on project's home page). It would most likely not work with PostSharp 3+ without major issues.

PostSharp(目前)通过 MSBuild 集成(正如 John Saunders 也提到的),网站项目不使用它.

PostSharp is (currently) integrated via MSBuild (as also mentioned by John Saunders), which is not used by website projects.

虽然 PostSharp 的核心是一个命令行工具,但它从 MSBuild 中获取了太多信息,以至于很难让它单独工作(并且一开始既不建议也不记录也不支持).

While in it's core PostSharp is a command-line tool, it gets so much information from MSBuild that it's quite hard to make it work separately (and neither advised nor documented nor supported in the first place).

P.S.:我目前为 PostSharp 技术工作.

P.S.: I currently work for PostSharp technologies.

这篇关于可以在网站项目中使用 postsharp 方面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆