datacontractserializer - How to resolve an error with WCF data contract -Message = "There was an error while trying to serialize parameter -
i have 2 data contracts of same contents in 2 different namespaces. have copied 1 datacontract and
passed particular method. giving below error , throwing exception. not going method.
please let me know ideas /suggestions on how resolve this.appreciate help:
exception errror: {"type 'system.collections.generic.list`1[[globalwcfservicelib.topicdetailsinfo, globalwcfcontracts, version=1.2.2.0, culture=neutral, publickeytoken=17c64733a9775004]]' data contract name 'arrayoftopicdetailsinfo:http://cname.globalservice/11.1/2010/11' not expected. consider using datacontractresolver or add types not known statically list of known types - example, using knowntypeattribute attribute or adding them list of known types passed datacontractserializer."}
message = "there error while trying serialize parameter http://cname.sharedservices.dbservicelib:subscriptiondatacontract. innerexception message 'type 'system.collections.generic.list`1 [[globalwcfservicelib.topicdetailsinfo, globalwcfcontra...
//////
here scenario : copying data dc new data contract below. after copying , when executing createsubscriptions method getting above mentioned error. have given details of data contract , error attached question. please refer well.
method1(subscriptiondatacontracts dc) { subscriptiondatacontract subscriptiondatacontract = new subscriptiondatacontract(); list<subscriptiontopicinfo> topicsinfo = dc.topiclist; list<subscriptiontopic> newtopicslist = new list<subscriptiontopic>(); subscriptiondatacontract.extensiondata = dc.extensiondata; subscriptiondatacontract.userid = dc.userid; (int = 0; < topicsinfo.count; i++) { subscriptiontopic topic = new subscriptiontopic(); topic.dbhandle = topicsinfo[i].dbhandle; topic.topic = topicsinfo[i].topic; topic.target = topicsinfo[i].target; newtopicslist.add(topic); } subscriptiondatacontract.topiclist = newtopicslist; createsubscriptions(subscriptiondatacontract); //getting above mentioned error in dll after going method }
//////////////////////////////// //my data contract
[datacontract(name = "topicdetailsinfo", namespace = "http://cname.globalservice")] [serializable] public class topicdetailsinfo { protected object topic; protected object baseobjecttype; [datamember] public object baseobjecttype { { return baseobjecttype; } set { baseobjecttype = value; } } [datamember] public object topicid { { return topic; } set { topic = value; } } static public topicdetailsinfo createtopic<t, mt>(icomparable<t> objecttype, icomparable<mt> objectid) { var topicdetails = new topicdetailsinfo(); topicdetails.baseobjecttype = objecttype; topicdetails.topicid = objectid; return topicdetails; } } [datacontract(name = "subscriptiontopicinfo", namespace = "http://cname.globalservice")] [knowntype(typeof(list<topicdetailsinfo>))] [serializable] public class subscriptiontopicinfo { private object topic; private object target; private object creator; [datamember] public object topic { { return topic; } set { topic = value; } } [datamember] public object target { { return target; } set { target = value; } } [datamember] public object dbhandle { { return creator; } set { creator = value; } } static public subscriptiontopicinfo createsubscriptions<t, mt, nt>(ilist<topicdetailsinfo> topic, icomparable<mt> target, icomparable<nt> handle) { var subscriptiontopic = new subscriptiontopicinfo(); subscriptiontopic.target = target; subscriptiontopic.topic = topic; subscriptiontopic.dbhandle = handle; return subscriptiontopic; } } [datacontract(name = "subscriptiondata", namespace = "http://cname.globalservice")] [knowntype(typeof(list<subscriptiontopicinfo>))] [serializable] public class subscriptiondatacontracts : iextensibledataobject { private extensiondataobject extensiondataobjectvalue; [datamember] public string userid { get; set; } [datamember] public string projectid { get; set; } [datamember] public string fromdiscipline { get; set; } [datamember] public string moduleid { get; set; } [datamember] public string sessionid { get; set; } [datamember] public list<subscriptiontopicinfo> topiclist { get; set; } public extensiondataobject extensiondata { { return extensiondataobjectvalue; } set { extensiondataobjectvalue = value; } } }
Comments
Post a Comment