tags:

views:

211

answers:

1

I'm looking into PostSharp as a means to bring logging into my team's projects. I'm running into an error when I try to create a sample aspect. I have some room to debug it, but I'd like to get some thoughts on where I might look.

I installed PostSharp, and when I first reference the PS dlls from my project, I get this exception on build:

Unhandled exception: PostSharp.AssertionFailedException: Invalid image. The token TypeRefResolutionScopeColumn is null.

I'm running Visual Studio 2008 SP1 on Windows Server 2008 SP2, 64-bit. I installed PostSharp with the 1.0SP1 64-bit installer, then I restarted Visual Studio. When I brought my (C# library) project up again, it built successfully. When I added references to PostSharp.Laos and PostSharp.Public, and tried to build, I got the error. I modified PostSharp and my project in no other way.

I can add the references successfully to a new project (and I see the PS banner in the output), just not to any of my existing projects. I've started ripping pieces out of my project, but haven't cleared the error. I can continue down this path, but I'm not real sure where it leads, and I'd love to have a signpost. I haven't found any reference to this exception. Has anyone else run into this?

Here's the full dump from my build output:

PostSharp 1.0 [1.0.12.469] - Copyright (c) Gael Fraiteur, 2005-2008.
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error : Unhandled exception: PostSharp.AssertionFailedException: Invalid image. The token TypeRefResolutionScopeColumn is null.
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.ModuleReader.ModuleReader.ImportTypeRefs()
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.ModuleReader.ModuleReader.ReadModule()
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.CodeModel.Domain.LoadAssembly(Assembly reflectionAssembly, Boolean lazyLoading)
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.CodeModel.Domain.GetAssembly(IAssemblyName assemblyName)
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.CodeModel.AssemblyRefDeclaration.GetAssemblyEnvelope()
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.CodeModel.TypeRefDeclaration.GetTypeDefinition(BindingOptions bindingOptions)
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.CodeModel.TypeRefDeclaration.GetTypeDefinition()
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.Extensibility.Tasks.CustomAttributeDictionaryTask.InternalAddAttribute(ICustomAttributeInstance attribute)
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.Extensibility.Tasks.CustomAttributeDictionaryTask.Execute()
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.Extensibility.Project.ExecutePhase(String phase)
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.Extensibility.Project.Execute()
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.Extensibility.PostSharpObject.ExecuteProjects()
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.Extensibility.PostSharpObject.InvokeProjects(ProjectInvocation[] projectInvocations)
C:\Program Files (x86)\PostSharp 1.0\PostSharp-1.0.targets(248,5): error :    at PostSharp.MSBuild.PostSharpRemoteTask.Execute(PostSharpTaskParameters parameters, TaskLoggingHelper log)
Done building project "[redacted].csproj" -- FAILED.
+1  A: 

Michael,

Please report bugs to http://www.postsharp.org/tracker.

I will need your source assembly to reproduce the problem. Which compiler are you using?

-gael

Gael Fraiteur
Filed (http://www.postsharp.org/tracker/view.php?id=366). I'm using csc 3.5.30729.1 from VS2008SP1. And yes, I'd assumed you'd need the assembly, and this being a standard dev house, it's unlikely I'll be able to give you that. I will ask, and I'll keep trying to reproduce this in an IP-less assembly. Thanks for your attention.
Michael Petrotta
Gael resolved the issue to an unusual, but legal, pattern in a third-party DLL we're using. Fix is targeted to PostSharp 1.0 SP2. Gael: thanks!
Michael Petrotta
The fix can be downloaded from http://www.postsharp.org/all-downloads/postsharp-1.0-development-builds (624).
Gael Fraiteur