DO 4.5.2

I have postsharp aspect:

[Serializable]
[AttributeUsage(AttributeTargets.Property)]
[MulticastAttributeUsage(MulticastTargets.Property, PersistMetaData = true)]
[AspectTypeDependency(AspectDependencyAction.Commute, typeof(TransactionalAttribute))]
public sealed class VirtualFieldAttribute : LocationInterceptionAspect
{
    ...
}

And when i try to use it:

...
[Field]
[VirtualField("Expression2")]
public DateTime CreatedSecond { get; set; }
...

I have exception on compilation my project:

Error   8   Unhandled exception (2.1.6.14, 32 bit, CLR 4.0, Release): System.NullReferenceException: Object reference not set to an instance of an object.
   at ^R00FfLNj7vE0.^rk33N/hO(OpCodeNumber _0, MetadataDeclaration _1)
   at ^R00FfLNj7vE0.EmitInstructionField(OpCodeNumber _0, IField _1)
   at PostSharp.Sdk.CodeModel.Instruction.Write(BaseInstructionWriter writer)
   at ^zpGNRK5nUM9z.^x98p/iJs13L+(InstructionReader _0)
   at PostSharp.Sdk.CodeModel.MethodBodyDeclaration.^uPrQJ6gs(InstructionBlock _0, IMethodBodyVisitor[] _1, InstructionAction _2, InstructionReader _3, InstructionBlockExceptionHandlingKind _4)
   at ^zpGNRK5nUM9z.^e2BtLyuT(^Kh85h0nXrulm& _0, Int32& _1)
   at ^zpGNRK5nUM9z.^SkiT(^ceSOybcTEumb _0)
   at PostSharp.Sdk.Binary.ModuleWriter.WriteMethodBodies(^ceSOybcTEumb _0, UInt32 _1)
   at ^Up6wxUIUnN6a.^VfvrABjR()
   at ^Up6wxUIUnN6a.^SkiT()
   at ^cyC/TYSlPGB/.^wvPm(^RtksFin57NJ8 _0, ^8gP93Xsl\+Imn _1)
   at PostSharp.Sdk.Extensibility.Tasks.CompileTask.Execute()
   at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
   at PostSharp.Sdk.Extensibility.Project.Execute()
   at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
   at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation)  C:\Projects\Platform\Werp.Models\POSTSHARP  Werp.Models

Do you have any ideas why it so?

update:

If I use OnMethodBoundaryAspect a have other exception:

Error   75  Unhandled exception (2.1.6.14, 32 bit, CLR 4.0, Release): System.NullReferenceException: Object reference not set to an instance of an object.
   at ^R00FfLNj7vE0.^rk33N/hO(OpCodeNumber _0, MetadataDeclaration _1)
   at ^R00FfLNj7vE0.EmitInstructionField(OpCodeNumber _0, IField _1)
   at PostSharp.Sdk.CodeModel.Instruction.Write(BaseInstructionWriter writer)
   at ^zpGNRK5nUM9z.^x98p/iJs13L+(InstructionReader _0)
   at PostSharp.Sdk.CodeModel.MethodBodyDeclaration.^uPrQJ6gs(InstructionBlock _0, IMethodBodyVisitor[] _1, InstructionAction _2, InstructionReader _3, InstructionBlockExceptionHandlingKind _4)
   at ^zpGNRK5nUM9z.^e2BtLyuT(^Kh85h0nXrulm& _0, Int32& _1)
   at ^zpGNRK5nUM9z.^SkiT(^ceSOybcTEumb _0)
   at PostSharp.Sdk.Binary.ModuleWriter.WriteMethodBodies(^ceSOybcTEumb _0, UInt32 _1)
   at ^Up6wxUIUnN6a.^VfvrABjR()
   at ^Up6wxUIUnN6a.^SkiT()
   at ^cyC/TYSlPGB/.^wvPm(^RtksFin57NJ8 _0, ^8gP93Xsl\+Imn _1)
   at PostSharp.Sdk.Extensibility.Tasks.CompileTask.Execute()
   at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)
   at PostSharp.Sdk.Extensibility.Project.Execute()
   at PostSharp.Hosting.PostSharpObject.ExecuteProjects()
   at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation)

Any more ideas?

asked May 15 '12 at 09:05

Multysh's gravatar image

Multysh
15669

edited May 15 '12 at 10:14


One Answer:

Hello Multysh,

our aspects rewrite properties in a very hard-core fashion. For example backing fields for auto-properties are removed from type completely. Probably this causes PostSharp to fail because it can't find backing field.

OnMethodBoundaryAspect should work because it operates on different level of abstraction.

answered May 15 '12 at 09:34

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov
179325

It does not work. I update post.

(May 15 '12 at 10:16) Multysh Multysh's gravatar image
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