• <tfoot id='e5ip9'></tfoot>

      <i id='e5ip9'><tr id='e5ip9'><dt id='e5ip9'><q id='e5ip9'><span id='e5ip9'><b id='e5ip9'><form id='e5ip9'><ins id='e5ip9'></ins><ul id='e5ip9'></ul><sub id='e5ip9'></sub></form><legend id='e5ip9'></legend><bdo id='e5ip9'><pre id='e5ip9'><center id='e5ip9'></center></pre></bdo></b><th id='e5ip9'></th></span></q></dt></tr></i><div id='e5ip9'><tfoot id='e5ip9'></tfoot><dl id='e5ip9'><fieldset id='e5ip9'></fieldset></dl></div>
    1. <legend id='e5ip9'><style id='e5ip9'><dir id='e5ip9'><q id='e5ip9'></q></dir></style></legend>
        <bdo id='e5ip9'></bdo><ul id='e5ip9'></ul>

      <small id='e5ip9'></small><noframes id='e5ip9'>

      1. 调用 JsonConvert.DeserializeObject&lt;T&gt; 时缺少

        时间:2023-08-23

            • <bdo id='WRyZH'></bdo><ul id='WRyZH'></ul>

              <tfoot id='WRyZH'></tfoot>
              • <small id='WRyZH'></small><noframes id='WRyZH'>

                • <i id='WRyZH'><tr id='WRyZH'><dt id='WRyZH'><q id='WRyZH'><span id='WRyZH'><b id='WRyZH'><form id='WRyZH'><ins id='WRyZH'></ins><ul id='WRyZH'></ul><sub id='WRyZH'></sub></form><legend id='WRyZH'></legend><bdo id='WRyZH'><pre id='WRyZH'><center id='WRyZH'></center></pre></bdo></b><th id='WRyZH'></th></span></q></dt></tr></i><div id='WRyZH'><tfoot id='WRyZH'></tfoot><dl id='WRyZH'><fieldset id='WRyZH'></fieldset></dl></div>

                    <tbody id='WRyZH'></tbody>
                  <legend id='WRyZH'><style id='WRyZH'><dir id='WRyZH'><q id='WRyZH'></q></dir></style></legend>
                • 本文介绍了调用 JsonConvert.DeserializeObject&lt;T&gt; 时缺少 System.Security.Permissions在 .NET Core 2.0 中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我目前正在考虑使用 .NET Core 2.0,以便可以在多个平台上运行我的应用程序.

                  I am currently looking at using .NET Core 2.0 so that I can run my app on multiple platforms.

                  我需要做的一件事是获取一个传入的字符串并将其反序列化为一个对象.例如

                  One thing I need to do is take an incoming string and deseralise it into an object. e.g.

                  var resultingObject = JsonConvert.DeserializeObject<MyDataContract>(request);
                  

                  在完整的 .NET 中,这将运行并返回我的对象​​.但是在 .NET Core 2.0 中出现以下异常

                  In full .NET, this would run and return me my object. However in .NET Core 2.0 I get the following exception

                  Could not load file or assembly 'System.Security.Permissions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
                  at Newtonsoft.Json.Serialization.JsonTypeReflector.get_DynamicCodeGeneration()
                   at Newtonsoft.Json.Serialization.JsonTypeReflector.get_ReflectionDelegateFactory()
                   at Newtonsoft.Json.Serialization.DefaultContractResolver.GetDefaultCreator(Type createdType)
                   at Newtonsoft.Json.Serialization.DefaultContractResolver.InitializeContract(JsonContract contract)
                   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateObjectContract(Type objectType)
                   at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract(Type objectType)
                   at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract(Type type)
                   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
                   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
                   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
                   at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
                  

                  经过一番阅读后,我在 StackOverflow 上发现了这一点,这表明 .NET Core 中不允许这种操作 https://stackoverflow.com/a/38385774/1211743

                  After some reading around I found this on StackOverflow which suggests that this kind of operation is not permitted in .NET Core https://stackoverflow.com/a/38385774/1211743

                  有人有什么见解吗?

                  推荐答案

                  这是由于对 .NET Core 的工作原理缺乏了解.我打开了 csproj 并添加了对所需文件System.Security.Permissions"的引用并重新加载了项目.至此,nuget 解决了.Json.NET 现在按预期工作.

                  This was due to a lack of understanding of how .NET Core works. I opened up the csproj and added a reference to the required file 'System.Security.Permissions' and reloaded the project. At this point, nuget resolved it. Json.NET now works as expected.

                  这篇关于调用 JsonConvert.DeserializeObject&lt;T&gt; 时缺少 System.Security.Permissions在 .NET Core 2.0 中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用带有 ItemRequired = Required.Always 的 Json.Net 反序 下一篇:覆盖自定义 JSON.net 合同解析器中的属性值

                  相关文章

                  最新文章

                      <bdo id='Aenql'></bdo><ul id='Aenql'></ul>

                  1. <legend id='Aenql'><style id='Aenql'><dir id='Aenql'><q id='Aenql'></q></dir></style></legend>
                  2. <i id='Aenql'><tr id='Aenql'><dt id='Aenql'><q id='Aenql'><span id='Aenql'><b id='Aenql'><form id='Aenql'><ins id='Aenql'></ins><ul id='Aenql'></ul><sub id='Aenql'></sub></form><legend id='Aenql'></legend><bdo id='Aenql'><pre id='Aenql'><center id='Aenql'></center></pre></bdo></b><th id='Aenql'></th></span></q></dt></tr></i><div id='Aenql'><tfoot id='Aenql'></tfoot><dl id='Aenql'><fieldset id='Aenql'></fieldset></dl></div>
                    1. <tfoot id='Aenql'></tfoot>

                    2. <small id='Aenql'></small><noframes id='Aenql'>