可以在网站项目中使用 postsharp 方面吗?

Can postsharp aspects be used on website projects?

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

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

请不要评论我为什么要使用网站而不是网络应用程序。很遗憾,这是一项要求(不要问)。

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

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

有一个 open-source project 可以实现这一点(CodingSource 也提到过)。但是,它是为 PostSharp 2.x 完成的,既不推荐也不支持(如项目主页所述)。如果没有重大问题,它很可能无法与 PostSharp 3+ 一起使用。

PostSharp(当前)通过 MSBuild(John Saunders 也提到)集成,网站项目不使用它。

虽然 PostSharp 的核心是一个命令行工具,但它从 MSBuild 获取了太多信息,因此很难单独使用它(而且一开始既没有建议也没有记录也没有支持)。

P.S.: 我目前从事 PostSharp 技术工作。