Uploaded image for project: 'Realm .NET SDK'
  1. Realm .NET SDK
  2. RNET-1001

InvalidOperationException: No properties in class, has linker stripped it?

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None

      What happened?

      I'm having problems using Realm, Realm cannot create LocalResData, LocalResData is in the assembly, and Realm Init is in other assembly.

      Unity: 2020.3.38f1
      Relam: 11.1.2
      Build:IL2CPP, Android

      I don't know how to solve this problem, can anyone help me?

      Repro steps

      After I build Android apk, this issue will definitely happen

      Version

      4.x

      What Atlas Services are you using?

      Local Database only

      What type of application is this?

      Unity

      Client OS and version

      Unity 2020.3.38f1

      Code snippets

      This is LocalResData

      using Realms;
      
      namespace Functions.Core.Realms.RealmModel
      {
          [Preserve(AllMembers = true)]
          public class LocalResData : RealmObject
          {
              [PrimaryKey, Preserve(AllMembers = true)] public int JoinId { get; set; }
              [Preserve(AllMembers = true)] public long Num { get; set; }
      
              public static void Init()
              {
              }
          }
      }
      

      This is init

      public static void New(string userId)
      {
          RealmConfiguration config = new RealmConfiguration($"{Application.persistentDataPath}/{userId}_JPG");
          config.Schema = new Type[]
          {
              typeof(LocalResData),
              typeof(TopicData)
          };
          config.EncryptionKey = Convert.FromBase64String(Url);
          config.SchemaVersion = 0;
          Realm = Realm.GetInstance(config);
      }
      

      I already have link.xml

      <linker>
          <assembly fullname="Functions.Core" preserve="all"/>
      </linker>
      

      Stacktrace of the exception/crash you're getting

      Unable to find source-code formatter for language: shell. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      This is the error log
      
      2023-06-27 00:20:41.927 22720-22873/? E/Unity: System.InvalidOperationException: No properties in LocalResData, has linker stripped it? See https://docs.mongodb.com/realm/sdk/dotnet/troubleshooting/#resolve-a--no-properties-in-class--exception
            at Realms.Schema.ObjectSchema+Builder..ctor (System.Type type) [0x00000] in <00000000000000000000000000000000>:0 
            at Realms.Schema.ObjectSchema+<>c.<FromType>b__23_0 (System.Type t) [0x00000] in <00000000000000000000000000000000>:0 
            at System.Func`2[T,TResult].Invoke (T arg) [0x00000] in <00000000000000000000000000000000>:0 
            at System.Collections.Concurrent.ConcurrentDictionary`2[TKey,TValue].GetOrAdd (TKey key, System.Func`2[T,TResult] valueFactory) [0x00000] in <00000000000000000000000000000000>:0 
            at Realms.Schema.RealmSchema+Builder.Add (System.Type type) [0x00000] in <00000000000000000000000000000000>:0 
            at Realms.Schema.RealmSchema+Builder..ctor (System.Collections.Generic.IEnumerable`1[T] types) [0x00000] in <00000000000000000000000000000000>:0 
            at Realms.Schema.RealmSchema.op_Implicit (System.
      

      ```

      Relevant log output

      No response

            Assignee:
            nikola.irinchev@mongodb.com Nikola Irinchev
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: