由于内部错误,服务器无法处理该请求。有关该错误的详细信息,请打开服务器上的 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; }
    }
}
相关推荐
ServBay39 分钟前
.NET 10 与 C# 14 更新速览,代码更少,性能更好
后端·c#·.net
玩泥巴的3 小时前
如何设计易维护、低学习成本的飞书.NET SDK组件
c#·二次开发·飞书·roslyn
Fighting_p4 小时前
【预览word文档】使用插件 docx-preview 预览线上 word 文档
开发语言·c#·word
jiushidt7 小时前
Things About ArcGISPro
arcgis·c#·.net·arcgispro
雪雁8 小时前
CodeSpirit 多语言国际化使用指南(Beta)
c#·asp.net·.net 10·codespirit
自己的九又四分之三站台8 小时前
写一个简单的DebugView
c#
CreasyChan8 小时前
C#中单个下划线的语法与用途详解
前端·c#
m5655bj8 小时前
如何通过 C# 实现 PDF 页面裁剪
前端·pdf·c#
STARBLOCKSHADOW8 小时前
【C#】VS中打包C#桌面软件为exe文件
c#·vs·打包·桌面程序
步步为营DotNet9 小时前
深度解析C# 11 的Required成员:编译期验证逻辑与稳健编程实践
java·服务器·c#