如何序列化 SubSonic 生成的类?

发布于 2024-09-10 12:28:32 字数 252 浏览 4 评论 0原文

我正在尝试将 SubSonic 与 WCF 一起使用。我可以将数据放入列表中,但无法将该数据返回到客户端,其错误是

套接字连接已被释放。对象名称: 'System.ServiceModel.Channels.SocketConnection'。

我尝试通过 POCO 对象向 WCF 发送和检索数据,它可以工作,但是当我尝试使用 SubSonic 生成的类时,它不再工作,所以我认为它有一些问题。

I'm trying to use SubSonic with WCF. I can get data into List but I can't return that data to client side, its error is

The socket connection has been disposed. Object name:
'System.ServiceModel.Channels.SocketConnection'.

I try to send and retrieve data to/from WCF by POCO object and it working but when I try to use generated class from SubSonic it don't work anymore, so I think its has some problem.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

飘落散花 2024-09-17 12:28:32

我认为这不是“真正的”例外。我对 WCF 不熟悉,但也许你在日志中找到了一些东西。

这是一篇关于调试 WCF 的文章 http://www.codeproject.com/KB/WCF /DebugWCFApps.aspx

最有可能的是,WCF 正在尝试序列化具有可为 null 属性的 SubSonic 类。
SubSonic 类的属性被标记为 XMLAttribute,如果您想要序列化可为 null 的类型,则会引发错误。 Nullable 只能序列化为 XMLElement。

尝试它是否适用于没有可为 null 属性的 SubSonic 生成的类。

I would assume that this is not the "real" exception. I am not familiar with WCF but maybe you find something in the logs.

Here is an article about debugging WCF http://www.codeproject.com/KB/WCF/DebugWCFApps.aspx

Most likely WCF is trying to serialize a SubSonic class with nullable properties.
Properties of SubSonic classes are marked as XMLAttribute, which throws an error if you want to serialize a nullable type. Nullables can only be serialized as XMLElements.

Try if it works with a SubSonic generated class that has no nullable property.

混吃等死 2024-09-17 12:28:32

当我下载了 SubSonic 的源代码并调试到 SubSonic.Core 后,我发现它出错了,因为 GetBody<>将创建该类的实例,并在其构造函数内尝试连接到数据库,但它无法连接;客户端无权访问数据库。

现在我正在努力使用 SubSonic 创建映射类并返回 POCO。

After I've downloaded source code of SubSonic and debug into it SubSonic.Core, I found that it error because GetBody<> will create instance of that class, and inside its constructor is trying to connect to database which it can't; client has no access to database.

Now I'm working on create mapping class with SubSonic and return POCO instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文