knah/Il2CppAssemblyUnhollower

Error Unhandled exception: System.Collections.Generic.KeyNotFoundException:

geokar2006 opened this issue · 16 comments

Unhandled exception: System.Collections.Generic.KeyNotFoundException: This key is missing from the dictionary.
in System.ThrowHelper.ThrowKeyNotFoundException()
in System.Collections.Generic.Dictionary`2.get_Item(TKey key)
in AssemblyUnhollower.Contexts.RewriteGlobalContext.GetNewAssemblyForOriginal(AssemblyDefinition oldAssembly)
in AssemblyUnhollower.Contexts.RewriteGlobalContext.GetNewTypeForOriginal(TypeDefinition originalType)
in AssemblyUnhollower.Passes.Pass11ComputeTypeSpecifics.ComputeSpecifics(TypeRewriteContext typeContext)
in AssemblyUnhollower.Passes.Pass11ComputeTypeSpecifics.DoPass(RewriteGlobalContext context)
in AssemblyUnhollower.Program.Main(UnhollowerOptions options)
in AssemblyUnhollower.Program.Main(String[] args)
How do I fix this error?

knah commented

Make sure you're using non-netcore version of Il2CppDumper.

If this happens even with non-netcore Il2CppDumper, more information would be required to investigate this. A good starting point would be the following:

  • The game you're trying to use it on, and its Unity version
  • The list of dummy assemblies produced by Il2CppDumper
  • Ideally an example Unity project that would lead to this

hey @knah I am having the same issue

C:\Users\Cloaker\Desktop\AssemblyUnhollower\net4.7.2>AssemblyUnhollower --input=C:\Users\Cloaker\Desktop\Il2CppDumper\net472\DummyDll --output=C:\Users\Cloaker\Desktop\Crackedrustcode\test --mscorlib=C:\Users\Cloaker\Desktop\Il2CppDumper\net472\DummyDll\mscorlib.dll
Reading assemblies... Done in 00:00:00.6767432
Computing renames... Done in 00:00:00.0718152
Creating typedefs... Done in 00:00:00.0511305
Computing struct blittability...
Unhandled Exception: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at AssemblyUnhollower.Passes.Pass11ComputeTypeSpecifics.ComputeSpecifics(TypeRewriteContext typeContext) in C:\Users\Cloaker\Desktop\Il2CppAssemblyUnhollower-master\AssemblyUnhollower\Passes\Pass11ComputeTypeSpecifics.cs:line 19
   at AssemblyUnhollower.Passes.Pass11ComputeTypeSpecifics.DoPass(RewriteGlobalContext context) in C:\Users\Cloaker\Desktop\Il2CppAssemblyUnhollower-master\AssemblyUnhollower\Passes\Pass11ComputeTypeSpecifics.cs:line 11
   at AssemblyUnhollower.Program.Main(UnhollowerOptions options) in C:\Users\Cloaker\Desktop\Il2CppAssemblyUnhollower-master\AssemblyUnhollower\Program.cs:line 160
   at AssemblyUnhollower.Program.Main(String[] args) in C:\Users\Cloaker\Desktop\Il2CppAssemblyUnhollower-master\AssemblyUnhollower\Program.cs:line 127
Done in 00:00:00.8784840

their is my full output the game I am trying to use it on is rust, with net472 version of Il2CppDumper, also not sure what version of unity rust uses but I think it is unity version 5.

knah commented

@CloakerTheCoder You're using wrong mscorlib path - it should be a proper mscorlib, not a dummy one.

Where might I find the proper one? because I could not find one in the game path. I understand this is a little of a newbie question but I am new to reverse engineering.

knah commented

Use the one that your managed domain injector uses. For MelonLoader, it's in MelonLoader/Managed directory.

Use the one that your managed domain injector uses. For MelonLoader, it's in MelonLoader/Managed directory.

Thanks for the help :D

Hello, I discovered this project along wirth MelonLoader a few hours ago and I'm having the same problem,
I'm using the latest version of Il2cppDumper(6.4.12) Il2CppAssemblyUnhollower(0.4.9.1) and MelonLoader(v0.2.7.1 Open-Beta) and when I try to run Il2CppAssemblyUnhollower I get the same error, even though I'm using the MelonLoader mscorlib.dll.
Do you know what could cause this problem ?

Actually it's the same exception but a different stacktrace, here's mine

   Unhandled exception: System.Collections.Generic.KeyNotFoundException: This key is missing from the dictionary.   
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at AssemblyUnhollower.Contexts.RewriteGlobalContext.GetAssemblyByName(String name)
   at AssemblyUnhollower.Passes.Pass60AddImplicitConversions.DoPass(RewriteGlobalContext context)
   at AssemblyUnhollower.Program.Main(UnhollowerOptions options)
   at AssemblyUnhollower.Program.Main(String[] args)```

My bad I was passing the Il2CppDumper's root folder instead of the DummyDll folder, but I'm still having issues

Unhandled exception : System.NullReferenceException:object reference not set to an instance of an object.
   at AssemblyUnhollower.Passes.Pass18FinalizeMethodContexts.DoPass(RewriteGlobalContext context)
   at AssemblyUnhollower.Program.Main(UnhollowerOptions options)
   at AssemblyUnhollower.Program.Main(String[] args)

Passing the Gameassembly.dll file with --gameassembly fixed it

Kein commented
--input="n:\1\DummyDll"
--output="n:\1\Unhollowed"
--mscorlib="e:\Games\Ori2\MelonLoader\Managed\mscorlib.dll"
Reading assemblies... Done in 00:00:01.7862085
Computing renames... Done in 00:00:00.0899269
Creating typedefs... Done in 00:00:00.0698732
Computing struct blittability... Done in 00:00:00.0064690
Filling typedefs... Done in 00:00:00.0276100
Filling generic constraints... Done in 00:00:00.0031081
Creating members... Done in 00:00:00.6362456
Scanning method cross-references... Done in 00:00:00.0023695
Finalizing method declarations...
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
   at AssemblyUnhollower.Passes.Pass18FinalizeMethodContexts.DoPass(RewriteGlobalContext context)
   at AssemblyUnhollower.Program.Main(UnhollowerOptions options)
   at AssemblyUnhollower.Program.Main(String[] args)

Ori 2 is Unity 2018.4.1
mscorlib 4.6.x
Il2Cpp dumper did its job fine:
https://pastebin.com/raw/MGYpPniD

knah commented

That's #5
In general, I'll close this issue, as it seems it doesn't happen with the correct Il2CppDumper version.

Kein commented

Nopes, not #5

Generating implicit conversions... Done in 00:00:00.0435103
Creating properties... Done in 00:00:00.0743007
Unstripping types... Done in 00:00:00.0311293
Unstripping methods...
Unhandled Exception: System.InvalidOperationException: Sequence contains more than one matching element
   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at AssemblyUnhollower.Passes.Pass80UnstripMethods.GetOrCreateProperty(MethodDefinition unityMethod, MethodDefinition
newMethod)
   at AssemblyUnhollower.Passes.Pass80UnstripMethods.DoPass(RewriteGlobalContext context)
   at AssemblyUnhollower.Program.Main(UnhollowerOptions options)
   at AssemblyUnhollower.Program.Main(String[] args)
Done in 00:00:07.0550312

After specifying --gameassembly and --unity

Use the one that your managed domain injector uses. For MelonLoader, it's in MelonLoader/Managed directory.

I'm using dnSpy to decompile, there is no mscorlib in the directory. Do I need to install MelonLoader if I have dnSpy

@knah Can you add adding additional information about mscorlib and --gameassembly flag in readme? It will be helpful for new users.

knah commented

@blueboy90780 Unhollower provides no additional information for decompiling. Generated assemblies only contain wrapper code to call into il2cpp.
@shazgames You can run unhollower without parameters for a help message. I suppose I could add it to readme too.