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 Unity - Manual: Managed plug-ins). 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?
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?
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.
You need to add a reference to UnityEngine.CoreModule to your library project. Not sure how it worked in the old machine.
@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!