首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PostSharp编译错误

PostSharp编译错误
EN

Stack Overflow用户
提问于 2010-03-05 22:51:39
回答 1查看 624关注 0票数 0

我遵循了postsharp 1.5附带的示例。我有两个简单的项目:

其中一个方面如下所示:

代码语言:javascript
复制
[Serializable]
public class MyAspectAttribute : OnMethodBoundaryAspect
{
    public override void OnEntry(MethodExecutionEventArgs eventArgs)
    {
        Console.WriteLine(eventArgs.Method.Name);
        base.OnEntry(eventArgs);
    }
}

在另一个项目中,我有一个这样的测试用例:

代码语言:javascript
复制
public class Test
{
    [MyAspect]
    public void DoSomething()
    {
        Console.Write("aa");
    }
}

在" test“的同一项目中,我有以下测试装置:

代码语言:javascript
复制
[TestFixture]
public class TestFixture
{
    [Test]
    public void TestDoSomething()
    {
        var a = new Test();
        a.DoSomething();
    }}

代码无法编译,因为出现了postsharp异常:

代码语言:javascript
复制
Error   2   Unhandled exception: System.InvalidCastException: Unable to cast object of type 'PostSharp.CodeModel.TypeDefDeclaration' to type 'PostSharp.CodeModel.IMethod'.
   at PostSharp.Laos.Weaver.MethodLevelAspectWeaver.get_TargetMethod()
   at PostSharp.Laos.Weaver.MethodLevelAspectWeaver.Initialize()
   at PostSharp.Laos.Weaver.OnMethodBoundaryAspectWeaver.Initialize()
   at PostSharp.Laos.Weaver.LaosTask.Execute()
   at PostSharp.Extensibility.Project.ExecutePhase(String phase)
   at PostSharp.Extensibility.Project.Execute()
   at PostSharp.Extensibility.PostSharpObject.ExecuteProjects()
   at PostSharp.Extensibility.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation)
   at PostSharp.MSBuild.PostSharpRemoteTask.Execute(PostSharpTaskParameters parameters, TaskLoggingHelper log)  MyExample.Tests

我该怎么办?

EN

回答 1

Stack Overflow用户

发布于 2010-03-06 21:31:46

它看起来像是一个bug,但我想知道你的样本是如何导致这个bug的。你有没有尝试过最新的版本,或者仅仅是RTM?

如果bug没有解决,你能给support@sharpcrafters.com发送一个repro (一个独立的命令行项目)吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2387549

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档