scottyboy805 / dotnow-interpreter

A pure C# CIL interpreter designed to load and execute managed code on IL2CPP (Unity) platforms.
MIT License
139 stars 16 forks source link

Android: FileNotFoundException: Could not find file "/mscorlib.dll" #4

Closed styrbo2 closed 3 years ago

styrbo2 commented 3 years ago

How to reproduce: 1) download last release version 0.0.9-beta 2) Change platform to Android, set .net version to 4.x and add ARM64 in Target Architectures 3) Build Snake example scene

This Exception canceled loading assembly

BlenMiner commented 3 years ago

I ran into this issue and tweaked the code to fix it. I can maybe find the change if you give me more information about the line that it fails or just the error log.

scottyboy805 commented 3 years ago

A stack trace or log file would be really helpful if you are able to provide one. Does it only happen for Android?

styrbo2 commented 3 years ago

that everything i got from logcat logcat stack trace

FileNotFoundException: Could not find file "/mscorlib.dll" at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, System.Int32 bufferSize, System.Boolean anonymous, System.IO.FileOptions options) [0x00000] in <00000000000000000000000000000000>:0 at System.IO.FileStream..ctor (System.String path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <00000000000000000000000000000000>:0 at Mono.Cecil.ModuleDefinition.GetFileStream (System.String fileName, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) [0x00000] in <00000000000000000000000000000000>:0 at Mono.Cecil.ModuleDefinition.ReadModule (System.String fileName, Mono.Cecil.ReaderParameters parameters) [0x00000] in <00000000000000000000000000000000>:0 at Mono.Cecil.BaseAssemblyResolver.GetAssembly (System.String file, Mono.Cecil.ReaderParameters parameters) [0x00000] in <000000000000000000000000

image

And yes its only happen on Android

BlenMiner commented 3 years ago

It happened to me on WebGL as well. And can you build the app in dev mode? The file line information isn't available beacuse you have a release build.

scottyboy805 commented 3 years ago

I was able to reproduce this on WebGL. It looks like the following change will fix the error, and I assume it will also resolve the problem on Android (No devices to test on). dotnow-#4 I will keep the issue open for now though because making the assembly loading deferred shifts the load time into the method execution as the module image is lazy loaded. That is something I really want to avoid so I will see if I can get immediate mode loading working somehow. Let me know if you have any thoughts.

scottyboy805 commented 3 years ago

Fixed in b9c3879. I could not find a workaround for the moment so deferred mode will have to stay until it becomes an issue.