首页 \ 问答 \ JSON反序列化仅在实时构建中抛出循环引用(JSON deserialization throws circular reference ONLY in live build)

JSON反序列化仅在实时构建中抛出循环引用(JSON deserialization throws circular reference ONLY in live build)

我有一个奇怪的问题,我无法解决这个问题。 我正在尝试为我的MVC4应用程序创建一个“export to csv”函数,其中相关的JSON通过ajax调用传递给我的ActionResult。 ActionResult反序列化stringify'd JSON(使用JSON.Net),将其写入csv格式的文件,然后将服务器路径返回到新文件。 然后我的成功回调接收路径并调用url进行下载。

这在本地工作正常,但在我的实时测试服务器上,我得到以下异常:

A circular reference was detected while serializing an object of type 'System.Reflection.RuntimeModule'.

JSON(以及随后被反序列化的对象)稍微复杂一些。 它们来自SlickGrid DataView的分组子集。 当我包含列总计的聚合信息时,我得到了循环引用异常(这只与那些精通SlickGrid的人有关,我不相信传递给服务器的数据是个问题),但是我已经删除了它们在将JSON传递给服务器之前。 这是我的JSON到C#类结构:

[Serializable]
public class Row
{
    public int id { get; set; }
    public DateTime DateCreated { get; set; }
    public int RefNo { get; set; }
    public string ClientName { get; set; }
    public string Plate { get; set; }
    public string Address1 { get; set; }
    public int? ProductID { get; set; }
    public string Product { get; set; }
    public string S1 { get; set; }
    public string S2 { get; set; }
}

[Serializable]
public class RootReportObject
{
    public bool __group { get; set; }
    public int level { get; set; }
    public int count { get; set; }
    public string value { get; set; }
    public string title { get; set; }
    public int collapsed { get; set; }
    public List<Row> rows { get; set; }
    public object groups { get; set; }
    public string groupingKey { get; set; }
}

我唯一想到的是,由于数据结构的方式,根对象中的List <>行可能在反序列化期间抛出循环引用,因为组不一定具有唯一的行引用。

我的问题是为什么它在当地运作良好? 我不知道我错过了什么。


I have a strange issue that I can't wrap my head around. I am trying to create an "export to csv" function for my MVC4 application where the relevant JSON is passed via an ajax call to my ActionResult. The ActionResult deserializes the stringify'd JSON (with JSON.Net), writes it to a file in csv format, then returns the server path to the new file. My success callback then receives the path and calls the url to download.

This works fine locally, but on my live test server I get the following exception:

A circular reference was detected while serializing an object of type 'System.Reflection.RuntimeModule'.

The JSON (and subsequently the objects they are deserialized to) are slightly complex. They come from a grouped subset of a SlickGrid DataView. I was getting circular reference exceptions when I included the aggregate information for column totals (this is only relevant to those that are versed in SlickGrid, I do not believe the data being passed to the server is an issue), but I've removed them before passing the JSON to the server. Here is my JSON to C# class structure:

[Serializable]
public class Row
{
    public int id { get; set; }
    public DateTime DateCreated { get; set; }
    public int RefNo { get; set; }
    public string ClientName { get; set; }
    public string Plate { get; set; }
    public string Address1 { get; set; }
    public int? ProductID { get; set; }
    public string Product { get; set; }
    public string S1 { get; set; }
    public string S2 { get; set; }
}

[Serializable]
public class RootReportObject
{
    public bool __group { get; set; }
    public int level { get; set; }
    public int count { get; set; }
    public string value { get; set; }
    public string title { get; set; }
    public int collapsed { get; set; }
    public List<Row> rows { get; set; }
    public object groups { get; set; }
    public string groupingKey { get; set; }
}

The only thing that I'm thinking is that, because of the way the data is structured, the List<> of rows in the root object may be throwing the circular references during deserializtion because a group does not necessarily have unique row references.

My question is why does it work fine locally?? I have no idea what I'm missing.


原文:https://stackoverflow.com/questions/19935331
更新时间:2022-09-18 12:09

最满意答案

.wrapInner {
text-align: center;
}
.Contents>.Logo {
margin: 15% 0 0 0;
}
.Contents>.SearchInput {
margin: 0 auto;
}

试试这个开始。 您需要用这些边距替换边距。

并且停止使用宽度设置为各像素量的固定宽度。

将此添加到您的身体

body{
width: 100%
}

您还需要在媒体质量中调整它。 然后沿着列表向下,并将所有容器的宽度设置为100%,而不是将它们设置为...


.wrapInner {
text-align: center;
}
.Contents>.Logo {
margin: 15% 0 0 0;
}
.Contents>.SearchInput {
margin: 0 auto;
}

Try this to start. You will need to replace the margins with these ones.

And stop using fixed widths you have widths set to amount of pixels everywhere.

Add this to your body

body{
width: 100%
}

you will also need to adjust it in your media quires. Then go down the list and set all your containers with widths set to 100% instead of what you got them set to...

相关问答

更多
  • 如果我正确地理解了你的问题,你愿意拥有容器高度和视口一样多。 我们举一个例子吧。 假设你有一个主div container ,它container其他所有东西,一个p标签显示container的当前大小以便显示,还有一个button来显示和隐藏banner : HTML
    Screen size is

    要根据窗口的高 ...
  • 你可以用#container替换min-height:100%高度:100%。 适用于IE8。 编辑:这是你在找什么? html { margin:0; padding:0; } body { background-color:FAF0E6; margin-top:35px; margin-bottom:10px; } #container { left:15px; width:60%; height:100%; position:relative ...
  • 移动到
  • 问题在于.css文件中的min-height属性。 我用.ui-page和.ui-page-active元素中的min-height: 500px替换了min-height: 100% ,并删除了该问题。 作为副作用,渐变颜色更加扩展,但这不应该是一个大问题。 The issue was with the min-height attribute in the .css file. I replaced min-height: 100% with min-height: 500px in .ui-page ...
  • .wrapInner { text-align: center; } .Contents>.Logo { margin: 15% 0 0 0; } .Contents>.SearchInput { margin: 0 auto; } 试试这个开始。 您需要用这些边距替换边距。 并且停止使用宽度设置为各像素量的固定宽度。 将此添加到您的身体 body{ width: 100% } 您还需要在媒体质量中调整它。 然后沿着列表向下,并将所有容器的宽度设置为100%,而不是将它们设置为... .wrapInne ...
  • 相机长宽比为4:3,您必须应用变换比例,以便您可以全屏显示 迅速 let screenSize = UIScreen.mainScreen().bounds.size let aspectRatio:CGFloat = 4.0/3.0 let scale = screenSize.height/screenSize.width * aspectRatio self.imagePikerViewController.cameraViewTransform = CGAffineTransformMakeScal ...
  • 您需要将这两行添加到您的头标记中,这将解决您的响应问题 最后一行是为了响应的目的 你有一个更多的CSS问题你的形象太大 适用于CSS下面,它会照顾它 .resume-itself img{ max-width: 100%; } you need to add this two lines in your head ta ...
  • 你如何隐藏/删除无用的底部黑条? 将targetSdkVersion设置为14或更高 。 最好不要提升targetSdkVersion? 用锋利的斧头砍掉手机底部。 请注意,这可能会使您在手机上的保修失效。 How do you hide/remove the useless bottom black bar? Set your targetSdkVersion to 14 or higher. Preferably without raising the targetSdkVersion? Chop th ...
  • 是的,固定位置页脚是要走的路:
    OK
    After a couple of experiments, I solved the problem with the lines of CSS below: #footer { color:#FFC; height:40px; position:fixed; bo ...
  • 是的,这是正常的,您的应用程序不支持4“屏幕大小。为了确保应用程序不破坏苹果将运行不支持3.5”模式的4“屏幕的应用程序。 为了让您的应用程序支持4“屏幕尺寸添加新的开始屏幕,名称为Default-568h@2x.png ,尺寸为640x1136 Yes this is normal, your app does not support the 4" screen size. To make sure that apps do not break apple will run apps that do no ...
  • 相关文章

    更多
  • Nutch 1-build
  • Hadoop在master查看live nodes为0解决方案
  • zoj 2966 Build The Electric System
  • redhat6.4上build storm 0.9.0.1
  • Gson对象序列化和反序列化
  • 【Hadoop】Build and Run HDFS
  • Java序列化
  • JSON部分序列化(二)
  • 重新Build Hadoop后进入Hive客户端异常
  • Hadoop 序列化的研究
  • 最新问答

    更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)