Search Unity

Question Error when building: System.BadImageFormatException: Could not resolve field token 0x04000025

Discussion in 'Editor & General Support' started by SLGSimon, Jul 20, 2021.

  1. SLGSimon

    SLGSimon

    Joined:
    Jul 23, 2019
    Posts:
    80
    I am randomly getting this error in automated builds (2020.3.11f1):

    (0,0): error System.BadImageFormatException: Could not resolve field token 0x04000025, due to: Could not load type of field 'Unity.Properties.CodeGen.Utility:s_AssemblyDefinedTypesQualifiedWithAttributes' (0) due to: Could not load file or assembly 'Unity.Properties, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. assembly:Unity.Properties, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null type:<unknown type> member:(null) signature:<none> assembly:D:\jenkins_agent\workspace\Eco Test Pipeline (develop)\Client\Library\ScriptAssemblies\Unity.Properties.CodeGen.dll type:Utility member:(null) signature:<none>

    I tried deleting the `Client\Library\ScriptAssemblies` folder before the build but that hasn't helped.

    Any ideas on what might be causing it or how to narrow it down?
     
    Last edited: Aug 4, 2021
    easycardgame and TJNBG like this.
  2. TJNBG

    TJNBG

    Joined:
    Apr 7, 2021
    Posts:
    24
    Seems to be a regression. 2020.3.8f1 does not exhibit this problem, however later builds do (checked 2020.3.14f1 and 2020.3.15f2)
     
  3. chechoggomez

    chechoggomez

    Unity Technologies

    Joined:
    Feb 25, 2013
    Posts:
    91
    Hi SLGSimon and TJNBG, do you have a reproduction project for this? Does it reproduce consistently? We have been looking for a project to reproduce it consistently for a while, but we haven't found anything yet.
    We are not sure what is causing it and that's why we are looking for reproduction projects.
     
  4. SLGSimon

    SLGSimon

    Joined:
    Jul 23, 2019
    Posts:
    80
    It seems pretty random, I am not able to repro it. We have many builds happening on two build machines. I could save the entire workspace after it happens but it's like 100GB all up. Would be happy to get you access to our project if it will help.
     
  5. cimrellik

    cimrellik

    Joined:
    Jul 1, 2020
    Posts:
    3
    I'm having the exact same issue, also on Jenkins using 2020.3.17f1. It's also happening very randomly, and doing the build with the exact same project state again usually works.
     
  6. reharrison_bbi

    reharrison_bbi

    Joined:
    Jun 26, 2015
    Posts:
    4
    Just to throw my hat in the ring, I got this error on launch of the editor, using 2020.3.17f1 as well. It forced the editor to launch in Safe Mode. Continuing to normal-mode did not fix it, but closing and relaunching the editor entirely seems to have cleared the issue.
     
  7. peeka

    peeka

    Joined:
    Dec 3, 2014
    Posts:
    113
    just ran into this with 2020.3.25, I was re-opening a project after it crashed, the project is work in progress so have existing compile error, once the project boot up it ask me if want to enter safe mode, and I did. and the error showed up, I google and found this post, I close the editor and reopen the error went away, and I am seeing my regular compile error again in safe mode.
     
  8. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    529
    I worked around this to get our CI stable again by adding a
    Thread.Sleep(1000);
    in
    com.unity.properties/Editor/Unity.Properties.CodeGen/PostProcessor.cs
    in the beginning of
    WillProcess
    .
     
  9. chechoggomez

    chechoggomez

    Unity Technologies

    Joined:
    Feb 25, 2013
    Posts:
    91
    erenaydin and easycardgame like this.
  10. erenaydin

    erenaydin

    Joined:
    Mar 1, 2011
    Posts:
    384
    I was having this issue consistently, for the first time. It started to happen after I run a code like this
    Code (CSharp):
    1. var inputs = events.Select(async ev => await ProcessEventAsync(ev))
    2.                    .Select(t => t.Result)
    3.                    .Where(i => i != null)
    4.                    .ToList();
    I don't know it's related or not tho.

    The error appeared and would not let me compile even If I restart Unity.
    It has been fixed after I downloaded com.unity.properties (I didn't have this before).
    I'm not sure if it's randomly fixed or not. It just helped :D
     
  11. Jointy87

    Jointy87

    Joined:
    Dec 19, 2019
    Posts:
    21
    Could you explain how I update my Unity.Properties? I don't really understand. Or do I need to update my entire Unity version for this? I'm on 2021.3.10f1. Thanks!

    EDIT: nvm I figured it out. Had to add it by name. But ok, here's the problem I'm having:

    For some reason I get this error at Unity start up every time. 4x the same error.
    I installed the lates Unity Properties (via com.unity.properies). Instead of helping, it increased the amount of error messages from 4 to 14. I downgraded unity properties to version 1.7.2, the one you mentioned, and it increased the amount of error messages to 100+. Now the funny thing is, when I removed the package completely, you'd expect to get back to the 4 error messages. But it hung at 96 orso. I'm really clueless as to what to do about this. I can't do anything with these errors like this.
     
    Last edited: Jan 4, 2023