SharpCrafters Forum – Unable to cast object of type 'PostSharp.CodeModel.TypeDefDeclaration' to type 'PostSharp.CodeModel.IMethod'.

SharpCrafters Support Forum

        


Unable to cast object of type... Expand / Collapse
Author
Message
Posted 3/5/2010 3:01:59 PM


Jose Fernando Romaniello

Community Member
I've followed the examples that come with postsharp 1.5 .. And I've two simple projects:

One of them has an aspect like this:

[Serializable]
public class MyAspectAttribute : OnMethodBoundaryAspect
{
   public override void OnEntry(MethodExecutionEventArgs eventArgs)
   {
       Console.WriteLine(eventArgs.Method.Name);
       base.OnEntry(eventArgs);
   }
}

In the other project I've a class like this:

public class Test
{
   [MyAspect]
   public void DoSomething()
   {
       Console.Write("aa");
   }
}

and the following test fixture:

[TestFixture]
public class TestFixture
{
   [Test]
   public void TestDoSomething()
   {
       var a = new Test();
       a.DoSomething();
   }}


The code wont compile because the following postsharp exception:

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

Thank you in advance.
Post #4090
Posted 3/9/2010 7:55:21 AM


Gael Fraiteur

SharpCrafters
Sorry, I did not notice your question.

I think I answered on StackOverflow: it's a bug and I would be glad if you could send me a repro.

Thanks.

-gael
Post #4117
Posted 3/9/2010 11:07:37 AM


Jose Fernando Romaniello

Community Member
Yes Gael thank you and sorry for duplicate the question...
Post #4118
« Prev Topic | Next Topic »


All times are GMT +1:00, Time now is 11:45am

Powered By InstantForum.NET v4.1.4 © 2010
Execution: 0.219. 8 queries. Compression Disabled.