Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Mono.Cecil throws ArgumentException on AssemblyDefinition.ReadAssembly()
System.ArgumentException: Value does not fall within the expected range.
at System.Runtime.CompilerServices.RuntimeHelpers.InitializeArray(Array array, RuntimeFieldHandle fldHandle)
at Mono.Cecil.Mixin.GetSize(CodedIndex self, Func`2 counter)
at Mono.Cecil.PE.Image.GetCodedIndexSize(CodedIndex coded_index)
at Mono.Cecil.PE.ImageReader.GetCodedIndexSize(CodedIndex index)
at Mono.Cecil.PE.ImageReader.ComputeTableInformations()
at Mono.Cecil.PE.ImageReader.ReadTableHeap()
at Mono.Cecil.PE.ImageReader.ReadMetadata()
at Mono.Cecil.PE.ImageReader.ReadImage()
at Mono.Cecil.PE.ImageReader.ReadImageFrom(Stream stream)
at Mono.Cecil.ModuleDefinition.ReadModule(Stream stream, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
at Mono.Cecil.AssemblyDefinition.ReadAssembly(String fileName, ReaderParameters parameters)
at NHtmlUnit.Generator.Program.Transform() in Program.cs:line 48
at NHtmlUnit.Generator.Program.Main(String[] args) in Program.cs:line 26

This comment has been minimized.

Copy link

@jbevain jbevain commented Dec 16, 2011

This in a .net bug which arises when using a Mono.Cecil.dll compiled with a Mono compiler on .net x64. The solution is to recompile it with Microsoft's csc, or use the nugget package.


This comment has been minimized.

Copy link
Owner Author

@asbjornu asbjornu commented Jan 18, 2012

Aha. Using the NuGet package indeed fixed the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.