Postsharp will crash if there is a method with an out or ref parameter.

Sample :

[Serializable]
  [HierarchyRoot]
  public class MyEntity : Entity
  {
    [Field, Key]
    public int Id { get; private set; }

    [Field(Length = 100)]
    public string Text { get; set; }

    public void DoSomething(out MyEntity myentity)
    {
      myentity = null;
    }

    public void DoSomething2(ref MyEntity myentity)
    {
      myentity = null;
    }
  }

Exception at compilation:

Error   1   Unhandled exception (2.0.5.1205, 32 bit, CLR 4.0, Release): System.InvalidOperationException: Operation is not valid due to the current state of the object.
   at PostSharp.AspectWeaver.Transformations.ArgumentsWriter.EmitLoadArguments(InstructionWriter instructionWriter)
   at PostSharp.AspectWeaver.Transformations.ArgumentsWriter.^C0S6plPn.EmitStoreByRefArgument(Int32 _0, InstructionWriter _1, Action`1 _2)
   at PostSharp.AspectWeaver.Transformations.ArgumentsWriter.EmitStoreByRefArgument(Int32 index, MethodMappingWriter methodMappingWriter, InstructionWriter instructionWriter)
   at ^1gq46AVh1jKu.^/1JyDPoZ5pES.^h4HWFf13.^MNbxG17j(ArgumentsWriter _0, MethodMappingWriter _1, InstructionWriter _2)
   at ^1gq46AVh1jKu.^/1JyDPoZ5pES.^h4HWFf13.WeaveOnException(InstructionBlock _0, ITypeSignature _1, InstructionWriter _2)
   at PostSharp.AspectInfrastructure.Helpers.MethodBodyWrappingImplementation.Implement(Boolean hasOnEntry, Boolean hasOnSuccess, Boolean hasOnExit, ITypeSignature[] exceptionTypes)
   at ^1gq46AVh1jKu.^/1JyDPoZ5pES.^h4HWFf13.^r4DISfQ8()
   at ^1gq46AVh1jKu.^/1JyDPoZ5pES.Implement(MethodBodyTransformationContext _0)
   at ^j1TTpdjykhlv.^LuETqvLKzZPB(MetadataDeclaration _0, MetadataDeclaration _1, MethodSemantics _2, InstructionBlock _3, Object[] _4, CanonicalMethodMapping _5, LocalVariableSymbol _6, InstructionSequence _7, TypeDefDeclaration _8, PipelineTransversalState _9)
   at ^MznFwdI/QV4L.^HvVDHXOj(MetadataDeclaration _0, IDependencyTransformationInstance[] _1, PipelineTransversalState _2, MethodSemantics _3)
   at PostSharp.AspectInfrastructure.AspectInfrastructureTask.^jwku0geZ(MetadataDeclaration _0, PipelineTransversalState _1, MethodSemantics _2, Boolean _3)
   at PostSharp.AspectInfrastructure.AspectInfrastructureTask.^KzeTZ0pV(IMetadataDeclaration _0)
   at PostSharp.AspectInfrastructure.StructuredDeclarationDictionary`1.^d+wOzSPF(IMetadataDeclaration _0, Func`2 _1)
   at PostSharp.AspectInfrastructure.StructuredDeclarationDictionary`1.^+g+TCqVg(TypeDefDeclaration _0, Func`2 _1, Set`1 _2)
   at PostSharp.AspectInfrastructure.StructuredDeclarationDictionary`1.^fJqG(Func`2 _0)
   at PostSharp.AspectInfrastructure.AspectInfrastructureTask.Execute()
   at PostSharp.Extensibility.Project.ExecutePhase(String phase)
   at PostSharp.Extensibility.Project.Execute()
   at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
   at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation)  d:\code\DoCrashPostsharp\DoCrashPostsharp\POSTSHARP DoCrashPostsharp

I will let you handle this one, because I do not know if this comes from an aspect implementation or postsharp.

I suspect this comes from the TransactionalAspect being broadcasted to all methods.

This is particularly cumbersome because the error does not indicate the file causing the exception : I had to manually remove all files to project, then re-add them one by one, then commenting methods one by one to find the source of the crash.


Updated at 25.05.2010 11:31:11

Thanks!

This thread was imported from our support forum. The original discussion may contain more detailed answer.

asked May 18 '10 at 13:36

olorin's gravatar image

olorin
356838489

edited Sep 08 '10 at 06:09

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

Thanks, I've opened the following issue: http://code.google.com/p/dataobjectsdot ... ail?id=655 for further investigation.

(May 18 '10 at 13:36) Dmitri Maximov Dmitri%20Maximov's gravatar image

I just reported this to PostSharp team. We'll try to fix the issue ASAP.

(May 18 '10 at 13:36) Alex Yakunin Alex%20Yakunin's gravatar image

Fixed in PostSharp v2.0.5.1207. This version is bundled into v4.3 RC2 - its installer will be available on this weekend.

(May 18 '10 at 13:36) Alex Yakunin Alex%20Yakunin's gravatar image

One Answer:

Fixed in PostSharp v2.0.5.1207

answered Sep 07 '10 at 04:16

olorin's gravatar image

olorin
356838489

Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA