Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Value cannot be null #2

Open
Numsgil opened this issue Mar 26, 2017 · 2 comments
Open

Value cannot be null #2

Numsgil opened this issue Mar 26, 2017 · 2 comments

Comments

@Numsgil
Copy link

Numsgil commented Mar 26, 2017

I'm getting an odd error. I've tracked it down to a specific type, but it's not obvious to me why it's causing problems.

Basically if I run:

Z:\Testing\ilstrip z:\Testing\testbed.exe /out:z:\Testing\testbedstrip.exe /v /keeptypes:MoonSharp,Scintilla,Priority,Sunweaver,Azimuth,Annulus,BotTestbed,System,Lima,Blacklight,Direct3D9,UnitTestSharp,SharpDX,System,UnitTestSharp.Assert,Seshat.DataDefinitions.ContextTypeDefinition,FlagsEnumTypeConverter,Seshat.CodeGenerator,Seshat.InstanceCodeGenerator,Seshat.TableCodeGenerator,Seshat.DataDefinitions.ContextTypeDefinition,Seshat.DynamicArrayMalloc,Seshat.SimulationLoop,Seshat.Virtual

I get a crash:

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
at Mono.Cecil.MetadataBuilder.LookupToken(IMetadataTokenProvider provider)
at Mono.Cecil.Cil.CodeReader.PatchRawCode(ByteBuffer buffer, Int32 code_size, CodeWriter writer)
at Mono.Cecil.Cil.CodeReader.PatchRawFatMethod(ByteBuffer buffer, MethodSymbols symbols, CodeWriter writer, Metad
ataToken& local_var_token)
at Mono.Cecil.Cil.CodeReader.PatchRawMethodBody(MethodDefinition method, CodeWriter writer, MethodSymbols& symbol
s)
at Mono.Cecil.Cil.CodeWriter.WriteUnresolvedMethodBody(MethodDefinition method)
at Mono.Cecil.Cil.CodeWriter.WriteMethodBody(MethodDefinition method)
at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddTypeDefs()
at Mono.Cecil.MetadataBuilder.BuildTypes()
at Mono.Cecil.MetadataBuilder.BuildModule()
at Mono.Cecil.ModuleWriter.b__0(MetadataBuilder builder, MetadataReader _)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
at Mono.Cecil.ModuleWriter.BuildMetadata(ModuleDefinition module, MetadataBuilder metadata)
at Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(Stream stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
at GK.ILStrip.Execute()
at GK.Program.Main(String[] args)

Not very helpful. If I change the command line to:

ilstrip z:\Testing\testbed.exe /out:z:\Testing\testbedstrip.exe /v /keeptypes:MoonSharp,Scintilla,
Priority,Sunweaver,Azimuth,Annulus,BotTestbed,System,Lima,Blacklight,Direct3D9,UnitTestSharp,SharpDX,System,UnitTestSharp.Assert,Seshat.DataDefinitions.ContextTypeDefinition,FlagsEnumTypeConverter,Seshat.CodeGenerator,Seshat.InstanceCodeGenerator,Seshat.TableCodeGenerator,Seshat.DataDefinitions.ContextTypeDefinition,Seshat.DynamicArrayMalloc,Seshat.SimulationLoop,Seshat.Virtual,Seshat.LuaDefinitions.LuaExecutor

I don't get a crash. The only difference between these lines is the addition of ,Seshat.LuaDefinitions.LuaExecutor at the end.

So something about Seshat.LuaDefinitions.LuaExecutor is causing problems. The code for it is here:
http://svn.darwinbots.com/Darwinbots3/Trunk/Modules/Seshat/Seshat/LuaDefinitions/LuaExecutor.cs

I don't think I'm doing anything too crazy in there, but who knows. I've also attached the testbed.exe binary.
testbed.zip

@Numsgil Numsgil changed the title Member is declared in another module and needs to be imported Value cannot be null Mar 26, 2017
@i00
Copy link

i00 commented Mar 25, 2019

I have the same error with this stack:

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: method
at Mono.Cecil.MethodSpecification..ctor(MethodReference method)
at Mono.Cecil.MetadataReader.ReadMethodSpecSignature(UInt32 signature, MethodReference method)
at Mono.Cecil.MetadataReader.GetMethodSpecification(UInt32 rid)
at Mono.Cecil.MetadataReader.LookupToken(MetadataToken token)
at Mono.Cecil.Cil.CodeReader.PatchRawCode(ByteBuffer buffer, Int32 code_size, CodeWriter writer)
at Mono.Cecil.Cil.CodeReader.PatchRawFatMethod(ByteBuffer buffer, MethodSymbols symbols, CodeWriter writer, MetadataToken& local_var_token)
at Mono.Cecil.Cil.CodeReader.PatchRawMethodBody(MethodDefinition method, CodeWriter writer, MethodSymbols& symbols)
at Mono.Cecil.Cil.CodeWriter.WriteUnresolvedMethodBody(MethodDefinition method)
at Mono.Cecil.Cil.CodeWriter.WriteMethodBody(MethodDefinition method)
at Mono.Cecil.MetadataBuilder.AddMethod(MethodDefinition method)
at Mono.Cecil.MetadataBuilder.AddMethods(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddType(TypeDefinition type)
at Mono.Cecil.MetadataBuilder.AddTypeDefs()
at Mono.Cecil.MetadataBuilder.BuildTypes()
at Mono.Cecil.MetadataBuilder.BuildModule()
at Mono.Cecil.ModuleWriter.b__0(MetadataBuilder builder, MetadataReader _)
at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TItem item, Func`3 read)
at Mono.Cecil.ModuleWriter.WriteModuleTo(ModuleDefinition module, Stream stream, WriterParameters parameters)
at Mono.Cecil.ModuleDefinition.Write(String fileName, WriterParameters parameters)
at GK.ILStrip.Execute()
at GK.Program.Main(String[] args)

Kris

@lander-vanhaverbeke-skyline
Copy link

lander-vanhaverbeke-skyline commented Apr 28, 2022

Same exception:
System.ArgumentNullException
HResult=0x80004003
Message=Value cannot be null.
Source=Mono.Cecil
StackTrace:
at Mono.Cecil.MetadataBuilder.LookupToken(IMetadataTokenProvider provider)

at ILStrip.Save

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants