1
votes

I am developing web application using WCF Service,i have created service and consumed that service in client application,i am uploading one text file for

matching the fileds after uploading the txt file,i am getting following error at client page

There was an error while trying to serialize parameter http://tempuri.org/:lblHide. The InnerException message was 'Type 'ASP.WCFApp_aspx' with data contract name 'WCFApp_aspx:http://schemas.datacontract.org/2004/07/ASP' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'. Please see InnerException for more details. ---> System.Runtime.Serialization.SerializationException: Type 'ASP.WCFApp_aspx' with data contract name 'WCFApp_aspx://schemas.datacontract.org/2004/07/ASP' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.

Please see the code below, WCFService.cs:

[OperationContract]

    [ServiceKnownType(typeof(string))]

    [ServiceKnownType(typeof(List<string>[]))]

    string KeyFieldsMatch(List<string>[] lst, Label lblHide, string strConn);

IWCFService.svc.cs:

public class WCFService: IWCFService

    {

  public string KeyFieldsMatch(List<string>[] lst, Label lblHide, string strConn)

    {

        try

        {

            return objBAL.KeyFieldsMatch(lst, lblHide, strConn);

        }

        catch

        {

            throw new FaultException("Error....");

        }

    }
}

Client:

WCFService.WCFServiceClient objBAL = new WCFService.WCFServiceClient();

 protected void btnSubmit_Click(object sender, EventArgs e)

    {

           List<string>[] list = new List<string>[2]

string[][] lst = new string[2][];

lst = list.Select(a => a.ToArray()).ToArray();

           string   KeyFieldsMatch =string.empty;

    KeyFieldsMatch = objBAL.KeyFieldsMatch(lst, lblHide, strConn);--Error coming at this location.
}

i am using basicHttpBinding

Any help would be appreciated.

1

1 Answers

1
votes

You are passing a UI object to the WCF service. What you should do is only passing the text value of the label as a string, not the complete label, because its is overkill and bad practice. Only send what you need.