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
最满意答案
.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...
相关问答
更多-
获得屏幕位置的底部(get bottom of screen position)[2022-02-25]
如果我正确地理解了你的问题,你愿意拥有容器高度和视口一样多。 我们举一个例子吧。 假设你有一个主div container ,它container其他所有东西,一个p标签显示container的当前大小以便显示,还有一个button来显示和隐藏banner : HTMLScreen 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 ...
-
导航不会触及屏幕底部(Navigation wont hit bottom of screen)[2023-07-24]
将标题- 移动到
-
问题在于.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 ...
-
JQuery移动底层空间(JQuery mobile bottom space)[2022-03-09]
是的,固定位置页脚是要走的路: 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 ...