SubSonic 3.0.0.2 结构.tt
我收到的错误似乎来自 Structs.tt 文件。 我正在使用 Northwind 数据库,并且仅使用 Products 表(我排除了所有其他表)。 我返回 Json(Product.All())。
这是错误:
检测到循环引用 序列化类型的对象时 'SubSonic.Schema.DatabaseColumn'。这里 堆栈跟踪:
System.InvalidOperationException 是 用户代码未处理 Message="A 检测到循环引用 序列化类型的对象 'SubSonic.Schema.DatabaseColumn'。” 来源=“System.Web.Extensions” 堆栈跟踪:位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeEnumerable(IEnumerable 可枚举、StringBuilder sb、Int32 深度,哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeEnumerable(IEnumerable 可枚举、StringBuilder sb、Int32 深度,哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(对象 o、StringBuilder sb、Int32 深度、 哈希表对象InUse, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.Serialize(对象 obj,StringBuilder 输出, 序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.Serialize(对象 obj,序列化格式 序列化格式)位于 System.Web.Script.Serialization.JavaScriptSerializer.Serialize(对象 对象)在 System.Web.Mvc.JsonResult.ExecuteResult(ControllerContext 上下文)在 System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext 控制器上下文、操作结果 行动结果)在 System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass11.b__e() 在 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter 过滤器,结果执行上下文 preContext,Func1 延续)位于 System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass11.<>c__DisplayClass13.b__10() 在 System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext、IList1 过滤器、 行动结果行动结果)在 System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext 控制器上下文,字符串操作名称) 在 System.Web.Mvc.Controller.ExecuteCore() 在 System.Web.Mvc.ControllerBase.Execute(RequestContext 请求上下文)在 System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext 请求上下文)在 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext)位于 System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext)位于 System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext)位于 System.Web.Mvc.MvcHttpHandler.VerifyAndProcessRequest(IHttpHandler httpHandler、HttpContextBase httpContext)位于 System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContextBase httpContext)位于 System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContext httpContext)位于 System.Web.Routing.UrlRoutingHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext 上下文)在 ExtJSNorthwind._Default.Page_Load(对象 发送者、EventArgs e) 中 C:\Applications\Spikes\ExtJSNorthwind\ExtJSNorthwind\Default.aspx.cs:line 18 于 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp、对象 o、对象 t、EventArgs e) 在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(对象 发送者、EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs 吃 System.Web.UI.Control.LoadRecursive() 在 System.Web.UI.Page.ProcessRequestMain(布尔值 includeStagesBeforeAsyncPoint,布尔值 includeStagesAfterAsyncPoint) 内部异常:
The error I'm getting seems to be coming out of the Structs.tt file. I'm using the Northwind db and only using the Products table (I excluded all other tables). I return Json(Product.All()).
Here's the error:
A circular reference was detected
while serializing an object of type
'SubSonic.Schema.DatabaseColumn'.Here's
the Stack Trace:System.InvalidOperationException was
unhandled by user code Message="A
circular reference was detected while
serializing an object of type
'SubSonic.Schema.DatabaseColumn'."
Source="System.Web.Extensions"
StackTrace: at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeEnumerable(IEnumerable
enumerable, StringBuilder sb, Int32
depth, Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeEnumerable(IEnumerable
enumerable, StringBuilder sb, Int32
depth, Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeCustomObject(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValueInternal(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.SerializeValue(Object
o, StringBuilder sb, Int32 depth,
Hashtable objectsInUse,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object
obj, StringBuilder output,
SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object
obj, SerializationFormat
serializationFormat) at
System.Web.Script.Serialization.JavaScriptSerializer.Serialize(Object
obj) at
System.Web.Mvc.JsonResult.ExecuteResult(ControllerContext
context) at
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext
controllerContext, ActionResult
actionResult) at
System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass11.b__e()
at
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter
filter, ResultExecutingContext
preContext, Func1 continuation) at
System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass11.<>c__DisplayClass13.b__10()
at
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext
controllerContext, IList1 filters,
ActionResult actionResult) at
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext
controllerContext, String actionName)
at
System.Web.Mvc.Controller.ExecuteCore()
at
System.Web.Mvc.ControllerBase.Execute(RequestContext
requestContext) at
System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext
requestContext) at
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase
httpContext) at
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext
httpContext) at
System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext
httpContext) at
System.Web.Mvc.MvcHttpHandler.VerifyAndProcessRequest(IHttpHandler
httpHandler, HttpContextBase
httpContext) at
System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContextBase
httpContext) at
System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContext
httpContext) at
System.Web.Routing.UrlRoutingHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext
context) at
ExtJSNorthwind._Default.Page_Load(Object
sender, EventArgs e) in
C:\Applications\Spikes\ExtJSNorthwind\ExtJSNorthwind\Default.aspx.cs:line
18 at
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr
fp, Object o, Object t, EventArgs e)
at
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object
sender, EventArgs e) at
System.Web.UI.Control.OnLoad(EventArgs
e) at
System.Web.UI.Control.LoadRecursive()
at
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint)
InnerException:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来我们在序列化方面遇到了问题:)。 您能否将此作为问题添加到我们的列表中? 我真的很感激。
Seems we have an issue with Serialization :). Can you please add this as an Issue on our list? I'd really appreciate it.
这很容易解决。 您只需将 ScriptIgnore 属性添加到 ActiveRecord.tt 文件中的几个方法即可。 以下是我所做的更改。
注意:我还在以下方法中添加了该属性,但我不知道您的情况是否需要它
This is fairly easy to fix. You need to just add a ScriptIgnore attribute to a couple of the methods in the ActiveRecord.tt file. Below are the changes that I made.
Note: I also added the attribute to the following method though I don't know if it is needed in your situation