今天在WCF项目里使用DataContract序列化接口参数的时候,报了这个错,错误详细信息如下:

System.ServiceModel.CommunicationException: There was an error while trying to serialize parameter http://tempuri.org/:reqDTO. The InnerException message was 'Type 'System.IO.FileStream' with data contract name 'FileStream:http://schemas.datacontract.org/2004/07/System.IO' 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 'System.IO.FileStream' with data contract name 'FileStream:http://schemas.datacontract.org/2004/07/System.IO' 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.

然后我就百度了一下,发现国外有个小哥也遇到相同的问题,别人给他的解释是:

DataContract messages serialize in a different way than MessageContract messages. Having a Stream member (thus allowing streaming) must be done using MessageContract, wcf then understands it is inteded for streaming and does not try to perform standard serialization.

意思是说DataContract序列化的方式和MessageContract消息序列化的方式不一样,如果你的WCF接口参数里包含有Stream(流类型),就必须用MessageContract。

Type 'System.IO.FileStream' with data contract name 'FileStream:http://schemas.datacontract.org/2004/07/System.IO' is not expected.的更多相关文章

  1. 谈谈WCF中的Data Contract(3):WCF Data Contract对Collection & Dictionary的支持

    谈谈WCF中的Data Contract(3):WCF Data Contract对Collection & Dictionary的支持 在本篇文章上一部分Order Processing的例 ...

  2. WCF技术剖析之十二:数据契约(Data Contract)和数据契约序列化器(DataContractSerializer)

    原文:WCF技术剖析之十二:数据契约(Data Contract)和数据契约序列化器(DataContractSerializer) [爱心链接:拯救一个25岁身患急性白血病的女孩[内有苏州电视台经济 ...

  3. System.Data.SqlClient.SqlError: FILESTREAM 功能被禁用”的错误

    还原sql2008数据库时遇到"System.Data.SqlClient.SqlError: FILESTREAM 功能被禁用"的错误,在网上搜索解决方案如下: 1.在" ...

  4. 解决:System.Data.SqlClient.SqlError: FILESTREAM 功能被禁用

    还原 AdventureWorks Sample DataBase 时遇到 FILESTREAM feature is disabled 错误提示. FileStream是SQL Server 200 ...

  5. XML序列化与REST WCF Data Contract匹配时遇到的2个问题

    问题一: XML序列化与RESTful WCF Data Contract不能匹配,无法传递类的值. 现象: 给类加上[Serializable]Attribute,可以成功序列化,但是WCF Ser ...

  6. 解决: org.iq80.leveldb.DBException: IO error: C:\data\trie\000945.sst: Could not create random access file.

    以太坊MPT树的持久化层是采用了leveldb数据库,然而在抽取MPT树代码运行过程中,进行get和write操作时却发生了错误: Caused by: org.fusesource.leveldbj ...

  7. fastboot 刷system.img 提示 sending 'system' (*KB)... FAILED (remote: data too large)

    华为G6-C00卡刷提示OEMSBL错误,只能线刷 ,但是官方找不到线刷img镜像,无奈 网上下了个可以线刷的工具套件 流氓ROM . 使用HuaweiUpdateExtractor(工具百度)把官方 ...

  8. System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.InvalidOperationException: 超时时间已到。超时时间已到,但是尚未从池中获取连接。出现这种情况可能是因为所有池连接均在使用,并且达到了最大池大小。

    2017/8/15 20:55:21 [AgentPayQuery_205506102_1BBBB]系统异常:System.Data.Entity.Core.EntityException: The ...

  9. Hive报错 Failed with exception java.io.IOException:java.lang.IllegalArgumentException: java.net.URISyntaxException: Relative path in absolute URI: ${system:user.name%7D

    报错信息如下 Failed with exception java.io.IOException:java.lang.IllegalArgumentException: java.net.URISyn ...

随机推荐

  1. cocos2d jsb 打包 Android APK

    1.首先要会普通的cpp 打包成Android APK 下面所说的是在cocos2d-x 2.2.2 或者 2.3 版本号中.本文在Eclipse总用ndk编译cocos2d-x. 老生常谈cocos ...

  2. 关于Javascript的内存泄漏问题的整理稿

    写了好长时间javascript小功能模块,从来没有关注过内存泄漏问题.记得以前写C++程序的时候,内存泄漏是个严重的问题,我想是时候关注一下了.网上找了篇文章,Mark一下.原文地址:http:// ...

  3. Android-Chat-Widget

    Original: https://github.com/ijarobot/Android-Chat-Widget Backup: https://github.com/eltld/Android-C ...

  4. Network Link Conditioner模拟不同网络环境

    在Xcode4.1中有一个工具叫Network Link Conditioner,可以让用户模拟不同的网络连接和带宽,可供Mac和iOS开发者测试自己的程序在不同网络环境下的表现. 在Xcode4.3 ...

  5. scala目录

    1. 使用Scala(构建这样一个应用,它会取回一份列表,其中包括用户持有的股票的代码以及股份,并告知他们在当前日期为止的这些投资的总价.这包含了几件事:获取用户输入.读文件.解析数据.写文件.从We ...

  6. 标准库 - fmt/print.go 解读

    // Copyright 2009 The Go Authors. All rights reserved. // Use of this source code is governed by a B ...

  7. 关于调试程序接收通过adb发送带有参数的广播问题

    一句话,如果你检查完格式没有错:关于通过adb启动Activity.activity.service以及发送broadcast的命令 am broadcast -a myAction --es cit ...

  8. 计算运行时间工具timeit

    Table of Contents 1. timeit的功能和用法 2. 其它 3. 参考资料 timeit的功能和用法 timeit 模块提供了测试一小段代码运行时间的功能.我前面有一篇文章用它来测 ...

  9. 3.3html学习笔记之链接

    iframe 元素会创建包含另外一个文档的内联框架 <iframe src=""/> 跳转链接 <a href="#here" target= ...

  10. A + B Again

    Problem Description There must be many A + B problems in our HDOJ , now a new one is coming.Give you ...