将转换类型'object []'转换为'System.Collections.ArrayList错误。 [英] Getting convert type 'object[]' to 'System.Collections.ArrayList error.

查看:75
本文介绍了将转换类型'object []'转换为'System.Collections.ArrayList错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在使用我的客户端应用程序一个wcf服务来回收一个arrylist。



我想验证wcf服务类中的所有属性,将所有错误消息作为arraylist显示返回给用户,



服务方法没问题就没问题了,它是returnig数组列表。



在ui转换类型'对象[]'到'System.Collections.ArrayList'中出现问题



如果有的话请告诉我解决方案。



这是我的代码



// UI类方法代码

[HttpPost]

public ActionResult Savedetails(DataEntity dataentity)

{

// arraylist

ArrayList arrayOfError = new ArrayList();

try

{

//将属性传递给WCF svc。

arrayOfError = _svcobjClint.SaveData(dataentity);



返回RedirectToAction(索引,数据实体);

}

catch(exception ex)

{

throw ex;

}

}



//服务层类方法代码

// Wcf服务方法

public ArrayList SaveData(DataEntity dataentity)

{

try

{

//验证方法它将找到错误并将所有错误返回为arraylist

ValidationsRules(dataentity);



//验证从这里开始(如果没有错误)它将允许将属性值发送到datalayer

if(arrayOfError.Count == 0)

{

SaveDatalayer savedatalayer = new SaveDatalayer() ;

savedatalayer.Save(dataentity);

}

}

catch(Exception ex)

{

throw ex ;

}

//将(作为数组列表的错误列表返回给UI)

返回arrayOfError;

}



当我尝试编译它时收到此消息:

无法将类型'object []'隐式转换为'System .Collections.ArrayList



有什么问题?如何从网络服务获取数组列表?



提前致谢,

Anand。

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.

推荐答案

添加 KnownType - 尝试这里 [ ^ ]。
Add the KnownType - try here[^].


这篇关于将转换类型'object []'转换为'System.Collections.ArrayList错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆