Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Exception type with Xamarin.Android and AppCenter SDK "is not marked as serializable." #524

Closed
alexsorokoletov opened this issue Nov 28, 2017 · 4 comments
Labels

Comments

@alexsorokoletov
Copy link

Hi!

Wondering, how do we resolve this warning below?
ApiException is defined in the PCL (I know I know) and is marked with [DataContract].

[MobileCenterCrashes] System.Runtime.Serialization.SerializationException: Type '***********.Sdk.Core.ApiException' in Assembly '***********.Sdk.Core, Version=1.0.6541.21029, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
[MobileCenterCrashes]   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize (System.Object obj, System.Runtime.Serialization.ISurrogateSelector surrogateSelector, System.Runtime.Serialization.StreamingContext context, System.Runtime.Serialization.Formatters.Binary.SerObjectInfoInit serObjectInfoInit, System.Runtime.Serialization.IFormatterConverter converter, System.Runtime.Serialization.Formatters.Binary.ObjectWriter objectWriter, System.Runtime.Serialization.SerializationBinder binder) [0x00107] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MobileCenterCrashes]   at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize (System.Object obj, System.Runtime.Serialization.ISurrogateSelector surrogateSelector, System.Runtime.Serialization.StreamingContext context, System.Runtime.Serialization.Formatters.Binary.SerObjectInfoInit serObjectInfoInit, System.Runtime.Serialization.IFormatterConverter converter, System.Runtime.Serialization.Formatters.Binary.ObjectWriter objectWriter, System.Runtime.Serialization.SerializationBinder binder) [0x00006] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MobileCenterCrashes]   at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize (System.Object graph, System.Runtime.Remoting.Messaging.Header[] inHeaders, System.Runtime.Serialization.Formatters.Binary.__BinaryWriter serWriter, System.Boolean fCheck) [0x0018b] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MobileCenterCrashes]   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph, System.Runtime.Remoting.Messaging.Header[] headers, System.Boolean fCheck) [0x0006e] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MobileCenterCrashes]   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph, System.Runtime.Remoting.Messaging.Header[] headers) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MobileCenterCrashes]   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize (System.IO.Stream serializationStream, System.Object graph) [0x00000] in <896ad1d315ca4ba7b117efb8dacaedcf>:0 
[MobileCenterCrashes]   at Microsoft.Azure.Mobile.Crashes.CrashesUtils.SerializeException (System.Exception exception) [0x0000c] in <39aacded211f4ad3ac8b3f87600853cf>:0 

Thank you!

@guperrot
Copy link
Member

Hi, your exception needs to have the [Serializable] attribute to be looked at on client side with our APIs after the restart with the getters. It does not impact any feature on server side though.

@guperrot
Copy link
Member

guperrot commented Nov 28, 2017

For PCL you can probably do this trick: https://stackoverflow.com/a/12903494/598520 to have access to the attribute.

@alexsorokoletov
Copy link
Author

@guperrot thank you for the advice!
I had to remove #if PORTABLE since in my PCL those symbols were not defined for some reason.
Other than that everything looks good.

Removing that "fake" attribute makes problem appear again.
We can close this issue.

@guperrot
Copy link
Member

Glad it worked for you, thanks for using App Center.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants