Show Blogger Panel Hide Blogger Panel
Alex Yakunin

October 2, 2009

Disappointing news: I can't merge everything to a single assembly

So v4.1 will contain only multiassembly version. For now I have no more time on investigating this issue. I stucked on the following one:

PEVerify on merged Xtensive.DataObjects.Net.dll prints this:
Microsoft (R) .NET Framework PE Verifier.  Version  2.0.50727.42
Copyright (c) Microsoft Corporation.  All rights reserved.

[MD]: Warning: MemberRef has a duplicate, token=0x0a000023. [token:0x0A000004]
[MD]: Warning: MemberRef has a duplicate, token=0x0a000035. [token:0x0A00000A]
... ~ 100 of such lines
[MD]: Warning: MemberRef has a duplicate, token=0x0a0004d9. [token:0x0A001BBE]
[IL]: Error: [C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net\bin\Debug-NoAspects\Xtensive.DataObjects.Net.dll : Xtensive.Storage.Aspects.PersistentAttribute::GetInternalConstructorSignatures][offset 0x00000048][found ref 'System.Object'][expected ref array mdarray 'System.Type[]'] Unexpected array type on the stack.
[IL]: Error: [C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net\bin\Debug-NoAspects\Xtensive.DataObjects.Net.dll : Xtensive.Storage.Aspects.PersistentAttribute::GetInternalConstructorSignatures][offset 0x00000068][found ref 'System.Object'][expected ref array mdarray 'System.Type[]'] Unexpected array type on the stack.
[IL]: Error: [C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net\bin\Debug-NoAspects\Xtensive.DataObjects.Net.dll : Xtensive.Storage.Aspects.PersistentAttribute::GetInternalConstructorSignatures][offset 0x00000099][found ref 'System.Object'][expected ref array mdarray 'System.Type[]'] Unexpected array type on the stack.
[IL]: Error: [C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net\bin\Debug-NoAspects\Xtensive.DataObjects.Net.dll : Xtensive.Storage.Aspects.PersistentAttribute::GetInternalConstructorSignatures][offset 0x000000DA][found ref 'System.Object'][expected ref array mdarray 'System.Type[]'] Unexpected array type on the stack.
[IL]: Error: [C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net\bin\Debug-NoAspects\Xtensive.DataObjects.Net.dll : Xtensive.Storage.Aspects.PersistentAttribute::GetInternalConstructorSignatures][offset 0x0000010B][found ref 'System.Object'][expected ref array mdarray 'System.Type[]'] Unexpected array type on the stack.
[IL]: Error: [C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net\bin\Debug-NoAspects\Xtensive.DataObjects.Net.dll : Xtensive.Storage.Aspects.PersistentAttribute::GetInternalConstructorSignatures][offset 0x00000158][found ref 'System.Object'][expected ref array mdarray 'System.Type[]'] Unexpected array type on the stack.
[IL]: Error: [C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net\bin\Debug-NoAspects\Xtensive.DataObjects.Net.dll : Xtensive.Storage.Aspects.PersistentAttribute::GetInternalConstructorSignatures][offset 0x00000189][found ref 'System.Object'][expected ref array mdarray 'System.Type[]'] Unexpected array type on the stack.
[IL]: Error: [C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net\bin\Debug-NoAspects\Xtensive.DataObjects.Net.dll : Xtensive.Storage.Linq.QueryHelper::CreateEntitySetQueryExpression][offset 0x000000F3][found ref 'System.Object'][expected ref 'System.Linq.Expressions.Expression'] Unexpected type on the stack.
[IL]: Error: [C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net\bin\Debug-NoAspects\Xtensive.DataObjects.Net.dll : Xtensive.Storage.Linq.QueryHelper::CreateEntitySetQueryExpression][offset 0x000001E8][found ref 'System.Object'][expected ref 'System.Linq.Expressions.Expression'] Unexpected type on the stack.
[IL]: Error: [C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net\bin\Debug-NoAspects\Xtensive.DataObjects.Net.dll : Xtensive.Storage.Rse.PreCompilation.Optimization.IndexSelection.RangeSetExpressionBuilder+<>c__DisplayClass3::<BuildSecondValueForLikeStartsWith>b__1][offset 0x00000059][found ref 'System.Object'][expected ref 'System.Linq.Expressions.Expression'] Unexpected type on the stack.
10 Errors Verifying C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net\bin\Debug-NoAspects\Xtensive.DataObjects.Net.dll(1334 Warnings)
Note that ILMerge does not print any error message, i.e. it considers its job is done well.

And it seems later this leads to inability to process the assembly by PostSharp (earlier I wrote, I decided to build the merged assembly combining non-PostSharped assemblies first, and to process it by PostSharp later - this ensures serialized aspects there will refer to correct assembly name):
  PostSharp parameters: Output=C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net\bin\Debug-NoAspects\Xtensive.DataObjects.Net.dll;ReferenceDirectory=C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net;Configuration=Debug;Platform=AnyCPU;SearchPath=bin\Debug-NoAspects\,obj\Debug\,;IntermediateDirectory=obj\Debug\PostSharp;CleanIntermediate=True;MSBuildProjectFullPath=C:\My Projects\Svn\Xtensive\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net\Xtensive.DataObjects.Net.csproj;SignAssembly=true;PrivateKeyLocation=..\..\Common\Key.snk
  PostSharp 1.0 [1.0.13.624] - Copyright (c) Gael Fraiteur, 2005-2008.
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error : Unhandled exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error : Parameter name: index
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error :    at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error :    at System.ThrowHelper.ThrowArgumentOutOfRangeException()
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error :    at PostSharp.ModuleReader.InstructionBlockBuilder.ProcessLexicalScope(ISymbolScope scope, InstructionBlock parentBlock, MethodBodyDeclaration methodBody, Byte* ilBytes, List`1 instructionBoundaries)
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error :    at PostSharp.ModuleReader.InstructionBlockBuilder.ProcessLexicalScope(ISymbolScope scope, InstructionBlock parentBlock, MethodBodyDeclaration methodBody, Byte* ilBytes, List`1 instructionBoundaries)
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error :    at PostSharp.ModuleReader.InstructionBlockBuilder.ProcessLexicalScope(ISymbolScope scope, InstructionBlock parentBlock, MethodBodyDeclaration methodBody, Byte* ilBytes, List`1 instructionBoundaries)
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error :    at PostSharp.ModuleReader.InstructionBlockBuilder.BuildInstructionBlockTree(MethodDefDeclaration methodDef)
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error :    at PostSharp.CodeModel.MethodDefDeclaration.get_MethodBody()
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error :    at PostSharp.Extensibility.Tasks.IndexUsagesTask.Execute()
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error :    at PostSharp.Extensibility.Project.ExecutePhase(String phase)
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error :    at PostSharp.Extensibility.Project.Execute()
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error :    at PostSharp.Extensibility.PostSharpObject.ExecuteProjects()
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error :    at PostSharp.Extensibility.PostSharpObject.InvokeProjects(ProjectInvocation[] projectInvocations)
C:\My Projects\Svn\Xtensive\Common\PostSharpILMerge.targets(102,5): error :    at PostSharp.MSBuild.PostSharpRemoteTask.Execute(PostSharpTaskParameters parameters, TaskLoggingHelper log)
So I'm raising up my hands here :( Later I'll contact Gael Fraiteur and Mike Barnett (ILMerge author) - may be they will give some insight on this. Since it's desirable to publish our source code first to make it easier to debug and study this, I'll wait till v4.1 release before making any further steps here.