Search Issue Tracker

By Design

Votes

0

Found in

2020.2.0a12

2020.2.0b7

2021.1

Issue ID

1286237

Regression

Yes

Exceptions during compile for ILPostProcessors with static constructors

Scripting

-

How to reproduce:
1. Open the attached project ("New Unity Project.zip")
2. Observe compile errors

Expected results: No compile errors
Actual results: System.MissingMethodException is thrown

Reproducible with: 2020.2.0a12, 2020.2.0b9, 2021.1.0a3
Not reproducible with: 2018.4.28f1, 2019.4.13f1, 2020.1.10f1, 2020.2.0a11

Note: Cause of error in PostProcessor.cs

Error:
(0,0): error System.MissingMethodException: Attempted to access a missing method.

Error with "EditorUtility.DisplayDialog("test", "test", "ok");" uncommented:
(0,0): error System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Test.CodeGen.PostProcessor' threw an exception. ---> System.MissingMethodException: Attempted to access a missing method.

  1. Resolution Note:

    You cannot call Unity APIs from ILPostProcessors, as they run outside of the Unity Editor process in 2020.2+ and inside a pure .NET application named ILPostProcessorRunner.

    You can use Console.WriteLine instead of Debug.Log to get text output redirected to the console/editor log.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.