Apologies if this is not the right place to ask about this error. I’ve been at this for 4-5 days.
Specs: protobuf-net 3.0.73 integrated into a Unity 2019.4.6f1 project that targets .NET Standard 2.0 when building for Xbox console with IL2CPP set to Low Stripping.
Exact log: “MissingMthodException: Default constructor not found for type ProtoBuf.Internal.PrimaryTypeProvider”
The project built in Editor works exactly as intended and that’s why I think it’s the IL2CPP stripping.
Error is reported when attempting to assign a new data field of ProtoTest.
Might be important to note that the ProtoTest class is a C# Library DLL coded and programmed outside of the Unity environment, as required per ProtoBuf Custom serialization. (To my knowledge). I then built it and ported it into Unity Plugins folder along with the matching Serializer.
ProtoTest saveFile = new ProtoTest(); // This is the call made where the code will fail
----- // Decorated class
[ProtoContract()]
public class ProtoTest
{
[ProtoMember(1)]
public string testString;
[ProtoMember(2)]
public int testint;
[ProtoMember(3)]
public int testBool;
[ProtoMember(4)]
public int[] testFixedIntArray;
[ProtoMember(5)]
public List<int> testList = new List<int>();
[ProtoMember(6)]
public Dictionary<int, string> testDictionary = new Dictionary<int, string>();
// This is the constructor that is being stripped (to my knowledge)
public ProtoTest() { }
}
I suspect that some off the protobuf files are being stripped during the build, I don’t have a lot of experience with handling this. However I attempted to omit the protobuf namespace from stripping by writing a Linker referencing the namespaces used to create all the protobuf data I know of.
Might be important to note that the ProtoTest class is a C# Library DLL coded and programmed outside of the Unity environment, as required per ProtoBuf Custom serialization. (To my knowledge).
Attempt 1
<linker>
<assembly fullname="ProtoBuf">
<namespace fullname="ProtoBuf.Internal.PrimaryTypeProvider" preserve="all"/>
</assembly>
</linker>
Attempt 2
<linker>
<assembly fullname="ProtoSave" preserve="all"/>
<assembly fullname="ProtoBuf" preserve="all"/>
<assembly fullname="ProtoBuf.Internal" preserve="all"/>
<assembly fullname="ProtoBuf.Meta" preserve="all"/>
</linker>
Attempt 3
<linker>
<namespace fullname="ProtoSave" preserve="all"/>
<namespace fullname="ProtoBuf" preserve="all"/>
<namespace fullname="ProtoBuf.Internal" preserve="all"/>
<namespace fullname="ProtoBuf.Meta" preserve="all"/>
<namespace fullname="ProtoBuf.Serializers" preserve="all"/>
<namespace fullname="DataSerializer" preserve="all"/>
</linker>