Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

encounter System.TypeInitializationException when I want to output the proto defined class

60 views
Skip to first unread message

欧阳兴旺

unread,
Oct 9, 2024, 3:40:10 AM10/9/24
to Protocol Buffers
sry my English is not that good,here is the problem
language:C# protobuf26.x
private void OnXXXChange(Logic.Protocol.XXX.XXXMsg msg)
{
    XLog.ILog(TAG, $"Recieve OnxxxxChange:{msg}");
}

the stacktrace
System.TypeInitializationException: The type initializer for 'Logic.Protocol.Hvac.HvacMsgReflection' threw an exception. ---> System.FormatException: The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or an illegal character among the padding characters.
at System.Convert.FromBase64CharPtr (System.Char* inputPtr, System.Int32 inputLength)
at Logic.Protocol.XXXX.XXXMsgReflection..cctor ()
at Logic.Protocol.XXXX.XXXX.get_Descriptor
at Google.Protobuf.JsonFormatter.Format (Google.Protobuf.IMessage message, System.IO.TextWriter writer)
at Google.Protobuf.JsonFormatter.Format (Google.Protobuf.IMessage message)

How does it happen?
I do`nt know,never seen it before.it was reported online,restart app donot solve,we can not keep the environment,and Restore Factory Settings it works well.




Message has been deleted

jons...@google.com

unread,
Oct 9, 2024, 11:09:04 AM10/9/24
to Protocol Buffers
It sounds like something has corrupted the generated code - perhaps a profanity filter that might have detected "rude" words embedded within base64 and modified them?

It seems unlikely that the generator has a bug here - even a one in a thousand corner case would have been seen many, many times by now.
If you're able to reproduce this in a minimal .proto file that contains no intellectual property, including that on the group would be fine.

If you aren't able to reproduce it like that, I would suggest trying to find a proto that reproduces the problem, and run protoc on multiple machines - do you end up with it sometimes working and sometimes not? Can you compare working and not working code?

欧阳兴旺

unread,
Oct 9, 2024, 10:13:49 PM10/9/24
to Protocol Buffers
thank u for your answer,I am sure that here is no difference between the error case and the correct one,the apk was only build once ,and it is reported only once that is the same code ,sometimes work and sometimes not ,I will try what u suggest,thank u again.
Reply all
Reply to author
Forward
0 new messages