Castle Dynamic Proxy IInvocation在.net Core和Framework中是否真的不同?

问题描述 投票:0回答:1

我有使用Castle DynamicProxy代理代码调用的代码。在Intercept(IInvocation调用)中,我使用NewtonSoft来Json序列化调用。

Newtonsoft.Json.JsonConvert.SerializeObject(invocation.Method);

在Framework中,这产生了一个看起来很简洁的东西:

{
"Name": "FastLoadDataAsJson",
"AssemblyName": "TinyData, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",
"ClassName": "Dimension2.Core.Database.TinyData",
"Signature": "Byte[] FastLoadDataAsJson(System.String, System.String, System.String)",
"Signature2": "System.Byte[] FastLoadDataAsJson(System.String, System.String, System.String)",
"MemberType": 8,
"GenericArguments": null
}

在.Net Core项目中,相同的序列化调用首先会出现此异常:

Self referencing loop detected for property 'ManifestModule' with type 'System.Reflection.RuntimeModule'. Path 'Module.Assembly'.'

我可以使用设置Newtonsoft.Json.ReferenceLoopHandling.Ignore来解决它>

但是我得到的JSON长93,000行!!!到底是怎么回事?看来调用完全不同。除了长度以外,属性是不同的,例如,没有Signature或Signature2属性。

简洁的Json框架似乎完全适合描述我们需要进行的调用。那么,Core为什么如此不同?我担心我缺少有关Castle,Core或两者的重要信息。

我有使用Castle DynamicProxy代理代码调用的代码。在Intercept(IInvocation调用)中,我使用NewtonSoft来Json序列化调用。 Newtonsoft.Json.JsonConvert ....

.net .net-core json.net castle-dynamicproxy binary-serialization
1个回答
0
投票

IInvocation.Method属性的类型为System.Reflection.MethodInfo,使用JSON.NET对对象进行JSON序列化的JSON与Castle Core无关。

© www.soinside.com 2019 - 2024. All rights reserved.