Invalid IL code (750194)

Hey, I encounter following issue during my work with Addressables.

InvalidProgramException: Invalid IL code in [...]/<NothingAsync>d__12:MoveNext (): IL_001c: call      0x0a000315
System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine] (TStateMachine& stateMachine) (at <7d97106330684add86d080ecf65bfe69>:0)
[...].NothingAsync () (at <e7100c1aed3a4fd79d4d8d0cb33b90bc>:0)
[...]+<[...]r>d__7.MoveNext () (at [...]:49)
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <7d97106330684add86d080ecf65bfe69>:0)
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) (at <7d97106330684add86d080ecf65bfe69>:0)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) (at <7d97106330684add86d080ecf65bfe69>:0)
System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) (at <7d97106330684add86d080ecf65bfe69>:0)
System.Runtime.CompilerServices.TaskAwaiter.GetResult () (at <7d97106330684add86d080ecf65bfe69>:0)

I am using async and await to instantiate the assets. With version 0.8.6 it worked well until I added many assets and groups. Then this error occured and I tried to fix with an update to 1.1.4.
I still have no clue how to fix it or what causes it, this is how my code looks like and also with an interesting workaround, maybe this gives a clue what is wrong. See the attached image.

I know that Addressables is not production ready, so this just my experience and maybe someone can use for something.

Have you tried with…

var gameObj = await Addressables.InstantiateAsync("key").Task;

Yes, I did, but with no luck. As soon as I write the “Addressables.InstantiateAsync” Line and go to playmode, the above described error occures. It is also not possible to debug this.

I have to take the last reply back, either it works with Task at the end or it is the new Unity 2019.1.10 version or both, now it works and I am very surprised.

1 Like

I found that where is something wrong with System.Runtime.CompilerServices.Unsafe.dll which is provided by com.unity.collection. I place a newer version of that dll and the problem solved. But every time I open unity, the appliction would change that automatically. So I have to replace that every time I use that. This is definitly a bug, hope unity will update their plugin soon.

I’ve just run into this problem. But it’s quite a relief that I’ve done nothing wrong. Hope this issue should be fixed soon.

Have any of you filled a bug with a repro project?

In my case, I’ve grpc in my plugins folder and it depends on a different version of the Unsafe.dll.
I moved unity.collections from packagecache into packages and deleted collections’ Unsafe.dll.
Unity uses the version alongside grpc in my plugins folder.

I had exactly the same error. To be exact, I think there are 2 different issues here:

  • AsyncOperationHandle can be awaited w/o compile error, but it will produce runtime error (so it’s easy to forget to access Task property and await the handle instead).
  • If I write await Addressables.LoadSceneAsync(addr).Task; I get the same error, but if I change this to:
var task = Addressables.LoadSceneAsync(addr).Task;
await task;

the error goes away.