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.