k

k

  • NA
  • 1
  • 0

WCF - CollectionDataContract issue...

Jul 20 2011 9:59 AM
In this below case, I am having my own class as datatype for one of datamember in other class type.
All the properties are decorated with datamember.

For example ;

====
class sample
{
public int id {get;set;}
}

===

Iam using the above class type in the below

Class trail
{
public string Name {get;set;}
public sample sampleid { get;set}
}

by adding service referece , While trying access from the UI , am getting the below error. Help me to sorted out this issue.

System.ServiceModel.FaultException was unhandled by user code
  Message=The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:oPeriodDTO. The InnerException message was 'The use of type '.Source.DataTransferObject.FiscalYearTypeDTO' as a get-only collection is not supported with NetDataContractSerializer.  Consider marking the type with the CollectionDataContractAttribute attribute or the SerializableAttribute attribute or adding a setter to the property.'.  Please see InnerException for more details.
  Source=mscorlib
  Action=http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault
  StackTrace:
    Server stack trace: 
       at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]: 
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at .Source.Registers.Registers.IRegisters.InsertPeriod(PeriodDTO oPeriodDTO)
       at .Source.Registers.Registers.RegistersClient.InsertPeriod(PeriodDTO oPeriodDTO) in D:\Source - TFS\.Source - BKP\Modules\Registers\Service References\Registers\Reference.cs:line 6509
       at .Source.Registers.Views.frmFiscalYearConfigPresenter.InsertPeriod(PeriodDTO oPeriod) in D:\Source - TFS\.Source - BKP\Modules\Registers\Views\frmFiscalYearConfigPresenter.cs:line 41
       at .Source.Registers.Views.frmFiscalYearConfig.CreateUpdatePeriod() in d:\Source - TFS\.Source - BKP\WebSites\.Source\Registers\frmFiscalYearConfig.aspx.cs:line 550
       at .Source.Registers.Views.frmFiscalYearConfig.toolBarPeriod_ToolBarClick(Object sender, ToolbarActionArgs e) in d:\Source - TFS\.Source - BKP\WebSites\.Source\Registers\frmFiscalYearConfig.aspx.cs:line 343
       at .Web.UserControls.SNToolBar.btnSave_Click(Object sender, ImageClickEventArgs e) in D:\Source - TFS\.Source - BKP\.Web.UserControls\SNToolBar.ascx.cs:line 44
       at System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e)
       at System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
  InnerException: 



Answers (2)