webservice asmx 无法序列化接口 System.Collections.Generic.IList

转载自:http://www.cnblogs.com/chenhuzi/p/4178194.html

今天有位同事在方法里加了一个IList<entity> 的返回值,也没有测试,直接发布,导致了如下错误。

NotSupportedException: 无法序列化接口 System.Collections.Generic.IList

InvalidOperationException: 反射“entity”时出错。

InvalidOperationException: 无法反射方法 method name 

InvalidOperationException: 无法处理请求。

InvalidOperationException: 处理请求失败。

最终查下来,web service 不支持这样的类型返回IList<entity> ,故将其改成 List<entity> 编译正常返回。

时间: 2024-08-24 08:35:01

webservice asmx 无法序列化接口 System.Collections.Generic.IList的相关文章

C#学习之System.Collections.Generic 与 System.Collections 记录

1.了解C#集合 System.Collections 命名空间 System.Collections 命名空间包含接口和类,这些接口和类定义各种对象(如列表.队列.位数组.哈希表和字典)的集合. 类   类 说明 ArrayList 使用大小可按需动态增加的数组实现 IList 接口. BitArray 管理位值的压缩数组,该值表示为布尔值,其中 true 表示位是打开的 (1),false 表示位是关闭的 (0). CaseInsensitiveComparer 比较两个对象是否相等,比较时

Resx 文件无效。未能加载 .RESX 文件中使用的类型 System.Collections.Generic.List`1请确保已在项目中添加了必需的引用。

在C#程序编写过程中,会遇到:Resx 文件无效.未能加载 .RESX 文件中使用的类型 System.Collections.Generic.List1`请确保已在项目中添加了必需的引用. 主要原因很可能是使用了类的可序列化的原因,代码如下: [Serializable] public class TimeLineItem { public string Title; public string Content; public TimeLineItem(string content) { th

vs2013c#测试using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1_CXY { class Program { stati

首先安装Unit Test Generator.方法为:工具->扩展和更新->联机->搜索“图标为装有蓝色液体的小试管.Unit Test Generator”, 编写代码,生成一个新的类,编写构造函数 与 add()函数.代码如下. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Co

System.Collections.Generic的各容器类的用法

演示System.Collections.Generic的各容器类的用法. 包括:Dictionary,KeyValuePair,SortedDic tionary,SortedList,HashSet,SortedSet,List,Queue,Stack等 1 System.Collections.Generic.Dictionary<>; //键/值对集合 2 System.Collections.Generic.KeyValuePair<>; //键/值对结构, 作为 Dic

使用泛型 类型System.Collections.Generic.KeyValuePair需要2个类型参数

c#在准备使用System.Collections.Generic.KeyValuePair遍历的Hashtable时候,代码却提示有错误: 这其实是个非常简单的错误,Eclipse中通过工具弹出的提示解决方法,点下鼠标就能解决问题的,Visual Studio 2010却不行. 不过提示也说的比较清楚了,需要指定两个参数的类型. 根据你的Hashtable中保存的Key和Value的数据类型指定就可以了. 例如: KeyValuePair<string, int> KeyValuePair&

[corefx注释说]-System.Collections.Generic.Queue&lt;T&gt;

为了节省时间,只写一些关注的方法好了,剩下的可以MSDN嘛XD 首先是声明部分,表示为队列是一个可用于枚举的只读集合 [DebuggerTypeProxy(typeof(QueueDebugView<>))] [DebuggerDisplay("Count = {Count}")] public class Queue<T> : IEnumerable<T>, System.Collections.ICollection, IReadOnlyColl

System.Collections.Generic.List&lt;T&gt; 与 System.Collections.ArrayList

[推荐] System.Collections.Generic.List<T> [原因] 泛型集合类List<T>在操作值类型的集合时可以不进行 装箱/拆箱 处理. 使得性能较 ArrayList提高了相当大的程度.因为托管堆中需要创建的对象次数减少了,所以需要应用程序执行的垃圾回收次数也相应减少.除此之外,开发人员还获得了编译时的类型安全性,源代码也因为强制类型转换的次数减少而变得更清晰.

System.Collections.Generic 源码阅读总结

ArrayList ,List ArrayList 和 List 都是不限制长度的集合类型 ,List相比ArrayList 就内部实现而言除了泛型本质没有太大区别.不过为避免装箱拆箱问题,尽可能使用List 集合内部是由数组实现,默认大小是4,但你使用无参构造函数构造实例时,内部数组大小是0,当你加入第一个元素时,才扩容为4,添加元素时,如果发现内置数组大小不够,内置数组大小会扩容为原来的两倍,每一次扩容都会重新开辟一个数组,拷贝旧数组的数据,如果你要给集合添加大量的元素却不为它初始化一个合适

System.Collections里的一些接口

System.Collections 名称空间中的几个接口提供了基本的组合功能:? IEnumerable 可以迭代集合中的项.? ICollection(继承于IEnumerable)可以获取集合中项的个数,并能把项复制到一个简单的数组类型中.? IList(继承于IEnumerable 和ICollection)提供了集合的项列表,允许访问这些项,并提供其他一些与项列表相关的基本功能.? IDictionary(继承于IEnumerable 和ICollection)类似于IList,但提供