Ria + Prism: "The return type must be an entity, a complex type, a set of complex types, or a predefined serializable type"

Source: Internet
Author: User

I recently encountered many unsolved problems in the RIA + siverlight project. It's really a headache. I have to think about it over and over again, and I'll write an article to record it. If anyone from other countries can pass this place, I would be more grateful if I could give some advice .. Let's talk less about the problem ..

Problem description: the server customizes an entity class that is not associated with the data and returns the object class through the method. There is no problem in compiling service. Web, but there is a problem during service compilation .. The error message is roughly as follows: 'The return type must be an entity or a collection of complex types or a predefined serializable type'. The first day was found online, but there is no solution. Finally, I was confused, but I still did not understand it ..

Entity class code:

[Metadatatypeattribute (typeof (unit. unitmetadata)] [datacontractattribute (isreference = true)] [serializable] public partial class unit {// <summary> // primary key // </Summary> [Key] [datamember] Public String ID {Get; set ;} [datamember] Public String member1 {Get; set;} internal sealed class unitmetadata {private unitmetadata () {} Public String ID {Get; set;} Public String member1 {Get; set ;}}}

Code:

     public partial class DomainSvcViolation     {        //[Invoke]        //public Unit QueryUnitInfo(string ID,string Member1)        //{          //   return new Unit()           // {             //    ID="123",
// Member1="test",            //};            //return this.GetVehInfo(plate_nbr, plate_type);        //}         [Invoke]        public Unit Test()        {            return new Unit() { ID = "123" };        }     }

When datamember is added, an error is reported. ''is marked as an attribute, but this attribute cannot be serialized. Is datamemberattribute missing? ''Later, the datamember attribute can be compiled.

However, when I add queryunitinfo again, the hateful error is reported. As follows:

    public partial class DomainSvcViolation     {        [Invoke]        public Unit QueryUnitInfo(object[] paras)        {             return new Unit()            {                 ID="123",
Member1="test",           };            return this.GetVehInfo(plate_nbr, plate_type);        }         [Invoke]        public Unit Test()        {            return new Unit() { ID = "123" };        }     }

If the method is used, an error is returned. 'The return type must be an entity or a collection of complex types or a predefined serializable type '.

You can change it .... The Code is as follows:

    public partial class DomainSvcViolation     {        [Invoke]        public Unit QueryUnitInfo(string Id)        {             return new Unit()            {                 ID="123",
Member1="test",           };            return this.GetVehInfo(plate_nbr, plate_type);        }         [Invoke]        public Unit Test()        {            return new Unit() { ID = "123" };        }     }

Have you seen the difference ?....

Supplement:

Public int setoprtinrole (list <t_asso_role_role> lstoprt, int roleid); the same error will be reported when such a method is signed.

Public int setoprtinrole (list <string> lstoprt, int roleid); this is fine.

Note: This signature can be compiled on some colleagues' machines. In addition, t_asso_role_role is the server class.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.