Base solution for your next web application
Open Closed

Invalid DataContract Exception in aspnetzero 10.1 #10684


User avatar
0
omkarchoudhari created

Prerequisites

  • What is your product version? 10.1.0
  • What is your product type (Angular or MVC)?Angular
  • What is product framework type (.net framework or .net core)?.net core

Query:

We are getting InvalidDataContractException warning with ASP Net Zero template version 10.1.0 We are receiving number of warnings in log file related with this Exception and when we deploy application on Azure, in AppInsights we are getting this as a failure count.

some of the exception list out the DTO name but some of exceptions are more generic and unable to figure out the exact cause of this. Can you please guide us to resolve these exceptions. ?

Generic Exception XmlDataContractSerializerOutputFormatter - An error occurred while trying to create a DataContractSerializer for the type 'Abp.Web.Models.AjaxResponse'. System.Runtime.Serialization.InvalidDataContractException: Type 'Abp.Web.Models.AjaxResponse`1[[System.Object, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]' cannot inherit from a type that is not marked with DataContractAttribute or SerializableAttribute. Consider marking the base type 'Abp.Web.Models.AjaxResponseBase' with DataContractAttribute or SerializableAttribute, or removing them from the derived type. at System.Runtime.Serialization.ClassDataContract.ClassDataContractCriticalHelper..ctor(Type type) at System.Runtime.Serialization.ClassDataContract..ctor(Type type)Exception showing for GetProfilePictureOutput Dto WARN 2021-11-17 16:45:27,915 [4 ] XmlDataContractSerializerOutputFormatter - An error occurred while trying to create a DataContractSerializer for the type 'SIRVA.Moving.Sales.Authorization.Users.Profile.Dto.GetProfilePictureOutput'. System.Runtime.Serialization.InvalidDataContractException: Type 'SIRVA.Moving.Sales.Authorization.Users.Profile.Dto.GetProfilePictureOutput' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute. Alternatively, you can ensure that the type is public and has a parameterless constructor - all public members of the type will then be serialized, and no attributes will be required.

Please guide us in resolving this exception urgently.

Thanks


2 Answer(s)
  • User Avatar
    0
    omkarchoudhari created

    Is there any update on this ? Requesting your team to look into this urgently as this app is soon to be launched on production.

    Thanks

  • User Avatar
    0
    musa.demir created

    Hi @omkarchoudhari

    Can you please add parameterless constructor method to GetProfilePictureOutput class.

            public GetProfilePictureOutput()
            {
                
            }