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

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

问题描述

我正在尝试在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中),但是就像我说的那样,它在Web应用程序项目中可以正常工作:

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.

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

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