【问题标题】:A circular reference was detected while serializing an object of type 'System.Globalization.CultureInfo'序列化“System.Globalization.CultureInfo”类型的对象时检测到循环引用
【发布时间】:2015-11-01 23:28:50
【问题描述】:

我正在尝试将我的 SQLite db 中的表获取到数据集中,但我收到错误消息“在序列化 'System.Globalization.CultureInfo' 类型的对象时检测到循环引用。”根据我在网上阅读的内容,我需要使用该属性,但我不知道在哪里。

这是我正在使用的 http 处理程序:

Imports System.Web.Script.Serialization

Public Class HTTPHandler
Implements System.Web.IHttpHandler

Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest

    Dim dataset = _Default.GetTables()

    Dim serializer As New JavaScriptSerializer

    Dim serDS = serializer.Serialize(dataset)

    context.Response.ContentType = "aplication/json"
    context.Response.ContentEncoding = Encoding.UTF8
    context.Response.Write(serDS)
End Sub

ReadOnly Property IsReusable() As Boolean Implements IHttpHandler.IsReusable
    Get
        Return False
    End Get
End Property

End Class

【问题讨论】:

    标签: vb.net httphandler circular-reference


    【解决方案1】:

    对不起,我的英语不好。我还在学习这门语言。

    那么,关于你的问题:

    试试:

    Dim serDS = serializer.Serialize(dataset.GetXml())

    理论上,Dataset 是可序列化的……但由于某种原因我不知道……如果你不转换为 xml,它就不起作用。

    再来一次,对不起我糟糕的英语=p

    【讨论】:

    • 是的,但它只是给了我一个很难解析的长字符串。有什么方法可以使用 ScriptIgnore 来忽略循环引用?
    猜你喜欢
    • 2010-10-14
    • 2012-05-04
    • 2012-12-01
    • 1970-01-01
    • 2015-01-21
    • 2010-11-12
    • 2013-04-23
    • 1970-01-01
    相关资源
    最近更新 更多