由于内部错误,服务器无法处理该请求。有关该错误的详细信息,请打开服务器上的 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; }
    }
}
相关推荐
柒儿吖4 小时前
基于 lycium 在 OpenHarmony 上交叉编译 komrad36-CRC 完整实践
c++·c#·harmonyos
在路上看风景5 小时前
2.1 反射
c#
斯内科7 小时前
C#德州扑克梭哈游戏(2):牌型与点数比较
游戏·c#·梭哈
柒儿吖7 小时前
rudp Reliable UDP 库在 OpenHarmony 的 lycium 适配与 CRC32 测试
c++·c#·openharmony
CreasyChan8 小时前
unity C# 实现屏蔽敏感词
unity·c#·游戏引擎
光泽雨8 小时前
C#中Process类详解
microsoft·c#·交互
柒儿吖8 小时前
三方库 Boost.Regex 在 OpenHarmony 的 lycium完整实践
c++·c#·openharmony
柒儿吖9 小时前
三方库 Emoji Segmenter 在 OpenHarmony 的 lycium 适配与测试
c++·c#·openharmony
hoiii1879 小时前
基于C#实现的高性能实时MP4录屏方案
开发语言·c#
yongui478349 小时前
基于C#实现Modbus RTU通信
开发语言·c#