Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Resolved Unity API code not working after moving project over to new Windows 11 machine

Discussion in 'Editor & General Support' started by Talthilas, Jul 5, 2022.

  1. Talthilas

    Talthilas

    Joined:
    Apr 1, 2014
    Posts:
    44
    I have been developing my game on a Windows 10 machine with no issues. I recently purchased a new Windows 11 machine and moved my project over. I made no changes - I simply copied it over. I am now receiving errors relating to Unity's API (i.e. DLL files) I have referenced in the project. The Unity editor version is the same on both machines.

    To be more specific, the problem is occuring in my managed class library project (i.e. DLL file) that references some of Unity's DLL files (these are all referenced in accordance with Unitys instructions here https://docs.unity3d.com/Manual/UsingDLL.html). The project seems to have no problem referencing Unity's DLL files, however whenever I try and reference a class within one of Unity's DLL's I get an error telling me that the type name could not be found in the namespace. I am targeting netstandard2.1 in my class library project and in my game.

    I am not having this issue on my old Windows 10 machine. Any ideas?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,109
    You should post the complete error message(s) so we better understand what the issue might be.

    If I understood correctly the issue isn‘t within Unity editor but in your library project that VS (or Rider) compiles into a DLL? Have you tried creating a new empty DLL project on the new machine to see if the issue happens even in new projects?

    Unity was installed via Hub, not just copied over from the old machine, right?
     
  3. Talthilas

    Talthilas

    Joined:
    Apr 1, 2014
    Posts:
    44
    Correct. It is a problem with the library project specifically - but only on the new Windows 11 machine.

    Yes I tried creating a new library project on the new machine that has a project reference to UnityEngine.dll. I had the same problem. The DLL itself throws no errors, but trying to use a class from the DLL does. I have attached an example of the error. Seems to be related to Windows 11, or else there is something not installed on the new machine that was on the old machine. I was thinking that this could be some sort of DLL versioning problem, but for the life of me I can't figure it out.

    Yes Unity was installed via the Hub.
     

    Attached Files:

  4. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    You need to add a reference to UnityEngine.CoreModule to your library project. Not sure how it worked in the old machine.
     
  5. Talthilas

    Talthilas

    Joined:
    Apr 1, 2014
    Posts:
    44
    @Neto_Kokku that fixed it! Sometimes the solution is right in front of you and you can still miss it! A combination of a 4k screen and tired eyes meant that I had accidently referenced UnityEditor.CoreModule rather than UnityEngine.CoreModule without noticing.

    Crisis averted. Thank you all!