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

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

      1. ODP.Net 驱动程序在 .NET Core 5.0 上引发异常

        时间:2023-06-25

            <small id='67IC3'></small><noframes id='67IC3'>

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

                  <tbody id='67IC3'></tbody>

                  <tfoot id='67IC3'></tfoot>
                  本文介绍了ODP.Net 驱动程序在 .NET Core 5.0 上引发异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在尝试将我的数据库应用程序从 .NET Core 3.1 移植到 .NET Core 5.0.

                  I am trying to port my database application from .NET Core 3.1 to .NET Core 5.0.

                  运行以下代码时,

                          public async Task<List<T>> LoadDataFromSQL<T, U>(string sql, U parameters, string connectionStringName)
                          {
                              using (IDbConnection connection = new OracleConnection(await GetConnectionString()))
                              {
                                  var rows = await connection.QueryAsync<T>(sql,
                                                                            parameters,
                                                                            commandType: CommandType.Text);
                                  return rows.ToList();
                              }
                          } 
                  

                  我收到此异常:

                  "System.Reflection.TargetInvocationException: 调用的目标已抛出异常. --->System.TypeInitializationException: 'OracleInternal.ServiceObjects.OracleConnectionImpl' 的类型初始值设定项引发异常. --->System.TypeInitializationException: 'Oracle.ManagedDataAccess.Types.TimeStamp' 的类型初始值设定项引发异常. --->System.NotSupportedException:BinaryFormatter 序列化和反序列化在此应用程序中被禁用.有关详细信息,请参阅 https://aka.ms/binaryformatter. 在 OracleInternal.Common.OracleTimeZone.GetInstance() 在 Oracle.ManagedDataAccess.Types.TimeStamp..cctor() --- 内部异常堆栈跟踪结束 --- 在 Oracle.ManagedDataAccess.Types.TimeStamp.InitializelatestTZversion() 在 OracleInternal.ServiceObjects.OracleConnectionImpl..cctor() --- 内部异常堆栈跟踪结束 --- 在 OracleInternal.ServiceObjects.OracleConnectionImpl..ctor() --- 内部结束,除了离子堆栈跟踪 --- "

                  "System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'OracleInternal.ServiceObjects.OracleConnectionImpl' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Oracle.ManagedDataAccess.Types.TimeStamp' threw an exception. ---> System.NotSupportedException: BinaryFormatter serialization and deserialization are disabled within this application. See https://aka.ms/binaryformatter for more information. at OracleInternal.Common.OracleTimeZone.GetInstance() at Oracle.ManagedDataAccess.Types.TimeStamp..cctor() --- End of inner exception stack trace --- at Oracle.ManagedDataAccess.Types.TimeStamp.InitializelatestTZversion() at OracleInternal.ServiceObjects.OracleConnectionImpl..cctor() --- End of inner exception stack trace --- at OracleInternal.ServiceObjects.OracleConnectionImpl..ctor() --- End of inner except ion stack trace --- "

                  是否可以通过我的应用程序解决此问题?

                  Is is possible to work around this from my application?

                  我使用的是最新版本的 Oracle.ManagedDataAccess.Core 2.19.91,发布于 2020 年 10 月 22 日.另外,我使用的是 Dapper 2.0.35.

                  I am using the latest version of Oracle.ManagedDataAccess.Core 2.19.91, release on 10/22/2020. Also, I am using Dapper 2.0.35.

                  推荐答案

                  我发现 Oracle 正在为此进行修复,该修复应该很快就会推出.

                  I discovered that Oracle is working on a fix for this which should be available soon.

                  与此同时,如果有人遇到此问题,有一个解决方法.

                  In the meantime, in case anyone runs into this issue there is a workaround.

                  在您的项目文件中,您可以将 XML 语句添加到 EnableUnsafeBinaryFormatterSerialization.

                  In your project file, you can add the XML statement to EnableUnsafeBinaryFormatterSerialization.

                    <PropertyGroup>
                      <TargetFramework>net5.0</TargetFramework>
                      <EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
                    </PropertyGroup>
                  

                  这篇关于ODP.Net 驱动程序在 .NET Core 5.0 上引发异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 Visual Studio 2013 中为 sqlite 配置实体框架 6 下一篇:.NET 5 从单个文件发布中排除了一些库

                  相关文章

                1. <legend id='ykUQG'><style id='ykUQG'><dir id='ykUQG'><q id='ykUQG'></q></dir></style></legend>

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

                    <bdo id='ykUQG'></bdo><ul id='ykUQG'></ul>
                3. <tfoot id='ykUQG'></tfoot>

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