Click here to Skip to main content
15,889,877 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am using my client application a wcf service that retuurns an arrylist.

I want to validate all properties in wcf service class to return all the error messages as arraylist display to user,

in service method no issues it is fine, it is returnig array list.

getting issue in ui "convert type 'object[]' to 'System.Collections.ArrayList"

Please let me know solution if any.

this is my code

// UI class method code
[HttpPost]
public ActionResult Savedetails(DataEntity dataentity)
{
//arraylist
ArrayList arrayOfError = new ArrayList();
try
{
//Passing properties to WCF svc.
arrayOfError = _svcobjClint.SaveData(dataentity);

return RedirectToAction("Index", dataentity);
}
catch (Exception ex)
{
throw ex;
}
}

//Service layer class method code
//Wcf services method
public ArrayList SaveData(DataEntity dataentity)
{
try
{
//validation method it will find the errors and return all errors as arraylist
ValidationsRules(dataentity);

//Validation Start Here (If no errors) it will allows to send property values to datalayer
if (arrayOfError.Count == 0)
{
SaveDatalayer savedatalayer = new SaveDatalayer ();
savedatalayer.Save(dataentity);
}
}
catch (Exception ex)
{
throw ex;
}
//returns the (list of errors as a array list to UI)
return arrayOfError;
}

When I try to compile it i getting this message:
Cannot implicitly convert type 'object[]' to 'System.Collections.ArrayList

What is the problem? how can I get the array list from the webservice?

Thanks in advance,
Anand.
Posted
Updated 23-Jan-15 23:26pm
v3

1 solution

Add the KnownType - try here[^].
 
Share this answer
 
Comments
[no name] 28-Jan-15 7:16am    
Thanks mate!

But getting issue like this:

An error occurred while receiving the HTTP response to http://localhost:2773/data.svc. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900