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.
5 comments:
It seems that ILMerge produces strange lexical scopes. Lexical scopes are badly define, so every compiler has different rules. PostSharp has some rules hard-coded, so it is known to work with C# and VB.NET. Now, if ILMerge produces yet different rules, I will have to implement these ones also.
Gael, I can send you the whole source code allowing to reproduce this on this weekend. It would be great if we could use ILMerge. Actually assembly it produces really can be loaded, but without PostSharp I can't even check if it fully works or not: it fails on Domain build, where presence of some aspects is checked.
P.S. Now source needs nothing special to be built. Just XCopy.
I can add that ILMerge seems anyway doing something wrong: you can find there are some errors, but PEVerify detects nothing in original assemblies (i.e. neither warnings nor errors).
I`d not recommend you to use ILMerge to create Libraries for developers.
I found the following ILMerge shortcomings:
* ILMerge removes XML Comments from resulting assembly. It is critical shortcoming!
* ILMerge can not create resulting .pdb file when any of source assemblies came without its .pdb (regardless "/ndebug" ILMerge option switched ON).
You should look for ILMerge alternative.
I prefer {SmartAssembly} for protecting and merging assemblies (but it is shareware).
Post a Comment