由于内部错误,服务器无法处理该请求。有关该错误的详细信息,请打开服务器上的 IncludeExceptionDetailInFaults

由于内部错误,服务器无法处理该请求。有关该错误的详细信息,请打开服务器上的 IncludeExceptionDetailInFaults (从 ServiceBehaviorAttribute 或从 <serviceDebug> 配置行为)以便将异常信息发送回客户端,或打开对每个 Microsoft .NET Framework SDK 文档的跟踪并检查服务器跟踪日志。

客户端调用WCF的时候报上面的错误,WCF只能序列化基础的数据类型,简单说只需要给客户端类上标记 [Serializable] 可序列化类问题就决绝了、

cs 复制代码
namespace ConsoleApplication1
{
    public class Program
    {
        static void Main(string[] args)
        {
            //获取数据
            BLL bll = new BLL();
            List<TB_StoreInfo> list = bll.GetModelList();//TB_StoreInfo = 客户端的数据模型

            //服务端 TB_StoreInfo 类
            List<ServiceReference1.TB_StoreInfo> list_StoreInfo = new List<ServiceReference1.TB_StoreInfo>();

            //TB_StoreInfo(客户端)类是无法直接赋值给ServiceReference1.TB_StoreInfo类
            //需要序列化TB_StoreInfo类  加  [Serializable]

            foreach (TB_StoreInfo item in list)
            {
                ServiceReference1.TB_StoreInfo _storeInfo = new ServiceReference1.TB_StoreInfo();
                _storeInfo.ID = item.ID;
                _storeInfo.Name = item.ID;
                _storeInfo.CreateDate = item.CreateDate;
                list_StoreInfo.Add(_storeInfo);
            }

            //然后就可以调用服务进行传参或返回值操作了,我这里是用来传递参数用的
            ServiceReference1.Check check = new ServiceReference1.Check();
            bool result = check.GetToList(list_StoreInfo);

            Console.ReadKey();
        }
    }

    public class BLL
    {
        private readonly DAL dal = new DAL();
        public List<TB_StoreInfo> GetModelList()
        {
            return dal.GetModelList();
        }
    }

    public class DAL
    {
        public List<TB_StoreInfo> GetModelList()
        {
            return new List<TB_StoreInfo>();
        }
    }
    [Serializable]
    public class TB_StoreInfo
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public DateTime CreateDate { get; set; }
    }
}
相关推荐
mudtools9 小时前
搭建一套.net下能落地的飞书考勤系统
后端·c#·.net
玩泥巴的19 小时前
搭建一套.net下能落地的飞书考勤系统
c#·.net·二次开发·飞书
唐宋元明清21881 天前
.NET 本地Db数据库-技术方案选型
windows·c#
lindexi1 天前
dotnet DirectX 通过可等待交换链降低输入渲染延迟
c#·directx·d2d·direct2d·vortice
qq_454245031 天前
基于组件与行为的树状节点系统
数据结构·c#
bugcome_com1 天前
C# 类的基础与进阶概念详解
c#
雪人不是菜鸡1 天前
简单工厂模式
开发语言·算法·c#
铸人1 天前
大数分解的Shor算法-C#
开发语言·算法·c#
未来之窗软件服务1 天前
AI人工智能(二十四)错误示范ASR张量错误C#—东方仙盟练气期
开发语言·人工智能·c#·仙盟创梦ide·东方仙盟
yong99901 天前
基于C#实现的UPnP端口映射程序
开发语言·c#