Search Unity

What is System.Private.CoreLib.dll and why is it giving me an error on UWP?

Discussion in 'Windows' started by Mikael-H, Jan 28, 2018.

  1. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    Background:

    Building for UWP, the app uses the REST client for Azure at https://github.com/Unity3dAzure/RESTClient.
    I am not sure if the REST client is to blame though because I can't figure out how to debug this.

    Problem:
    When I run the build from visual studio I get an error message in the Development Console saying:

    Error could not find assembly System.Private.CoreLib.dll in which type System.Action'1[RESTClient.IRestResponse'1[LineOfBattleWebBackend.Application.Dtos.ScoreDtoOutput[]]] resides

    The class ScoreDtoOutput is just a basic serialized class with no strange namespaces or anything.

    Questions:
    The interface IRestResponse has a reference to System.Net which I was thinking maybe was not available on Core? I tried to look it up and it looks like it is available on Nuget for core, do I need to add it manually or something?

    Also, what the heck is System.Private.CoreLib.dll?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    System.Private.CoreLib.dll is the main runtime library on .NET core (think of mscorlib.dll). Can you post full log? Are you passing a type like this into Unity's APIs somewhere?
     
    Mikael-H likes this.
  3. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    I don't get an actual exception that I can see in VS2017, only the error in the Development Console. I tried turning off "my code only" but still do not get an exception.

    Actually, I can't find anything that goes wrong either, everything seems to work, except for the print to the concole, but I don't want this coming back to haunt me later :)
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Yeah it's just a thing we log in the console. But can you paste the full thing? This might have performance implications.
     
  5. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    Umm I don't see a stack trace, I am talking about the console in the built unity app here. Or do you mean from a log file somewhere?
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    I'm talking about the contents of the output window where you see this message.
     
  7. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    The entire contents of the window are:

    Error could not find assembly System.Private.CoreLib.dll in which type System.Action'1[RESTClient.IRestResponse'1[LineOfBattleWebBackend.Application.Dtos.ScoreDtoOutput[]]] resides

    No extra info comes up if I try to expand the message
     
    Last edited: Jan 30, 2018
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    There should be whole bunch of stuff in Visual Studio output window. You could also get the contents of the player log on disk at %LOCALAPPDATA%\Packages\<your_app_package_name>\TempState\UnityPlayer.log.
     
  9. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    Ok, thanks, I'll have a look! I need to learn more about debugging for UWP, obviously...
     
  10. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    This is the output in VS:
    Warning: unknown type VikingCrewDevelopment.OnlineHighscores.RestApiService+<Get_Coroutine>d__19`1[LineOfBattleWebBackend.Application.Dtos.ScoreDtoOutput[]] detected. Using reflection to gather its type information. Consider to reference it from your scripts so it can gathered during the build process.

    (Filename: C:\buildslave\unity\build\Runtime/ScriptingBackend/DotNet/ScriptingTypeProvider_DotNet.cpp Line: 154)


    I don't really understand that error though. The classes are referenced in code allright. And they are not in another DLL, they are in the Plugins folder so should be in firstpass-dll or whatever it is called.
     
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    What unity version are you on? Can you show how that class is used from code?

    This shouldn't have any secret issues, except for the fact that Unity will use reflection to gather type information first time it sees that type. It means Unity couldn't find that class during build type.
     
  12. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    I'm on 2017.3, if you want me to test on another version, let me know.

    This is how the class i used:
    Code (csharp):
    1.  
    2. public IEnumerator GetNearbyScores(int numScores, int score, Action<ScoreDtoOutput[]> callback = null, Action<string> errorCallback = null)
    3.         {
    4.             Action<IRestResponse<ScoreDtoOutput[]>> restCallback = (response) =>
    5.             {
    6.                 if (response.IsError && errorCallback != null)
    7.                     errorCallback(response.ErrorMessage);
    8.                 if (!response.IsError && callback != null)
    9.                     callback(response.Data);
    10.             };
    11.             yield return Get_Coroutine<ScoreDtoOutput[]>(_apiUrl + "scores/nearby/" + numScores  + "/" + score, restCallback);
    12.         }
    13.  
    This is the class:

    Code (csharp):
    1.  
    2. using System;
    3.  
    4. namespace LineOfBattleWebBackend.Application.Dtos
    5. {
    6.     [Serializable]
    7.     public class ScoreDtoInput
    8.     {
    9.      
    10.         public int Waves;
    11.         public int Rank;
    12.         public string UserName = "Unknown Soldier";
    13.         public int Platform;
    14.         public string Transmogrification;
    15.  
    16.         public ScoreDtoInput() { }
    17.  
    18.         public override string ToString()
    19.         {
    20.             return Rank + " " + UserName + " " + Waves + " waves ";
    21.         }
    22.     }
    23.     [Serializable]
    24.     public class ScoreDtoOutput : ScoreDtoInput
    25.     {
    26.         public Guid Id;
    27.         public Guid UserId;
    28.         public int ListPosition;
    29.         public ScoreDtoOutput() { }
    30.  
    31.         public override string ToString()
    32.         {
    33.             return base.ToString();
    34.         }
    35.     }
    36. }
    37.  
    38.  
     
  13. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Yeah, Unity probably doesn't see that generic instantiation - I believe we scan method signatures only. Just to test something: what happens if you add an empty method taking whatever Get_Coroutine<ScoreDtoOutput[]> returns?
     
  14. Mikael-H

    Mikael-H

    Joined:
    Apr 26, 2013
    Posts:
    309
    Sorry for the late reply, it took some time before I could test this, but yeah, that removed the error so you're probably right!

    I am happy with that solution but let me know if you want me to test something else. Thank you so much for always taking the time to help and explaining a little bit what goes on under the hood :) This isn't the first time you help me and probably not the last either :)
     
  15. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    You're welcome :)
     
    Mikael-H likes this.