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

        <legend id='Kw9Ya'><style id='Kw9Ya'><dir id='Kw9Ya'><q id='Kw9Ya'></q></dir></style></legend>

        ODP.Net 驱动程序在 .NET Core 5.0 上抛出异常

        时间:2023-06-06

          <tfoot id='FCtQ9'></tfoot>

          • <small id='FCtQ9'></small><noframes id='FCtQ9'>

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

                  本文介绍了ODP.Net 驱动程序在 .NET Core 5.0 上抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在尝试将我的数据库应用程序从 .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: 调用的目标已抛出异常.\r\n --->System.TypeInitializationException: 'OracleInternal.ServiceObjects.OracleConnectionImpl' 的类型初始值设定项引发异常.\r\n --->System.TypeInitializationException: 'Oracle.ManagedDataAccess.Types.TimeStamp' 的类型初始值设定项引发异常.\r\n --->System.NotSupportedException:此应用程序中禁用了 BinaryFormatter 序列化和反序列化.有关详细信息,请参阅 https://aka.ms/binaryformatter.\r\n 在 OracleInternal.Common.OracleTimeZone.GetInstance()\r\n 在 Oracle.ManagedDataAccess.Types.TimeStamp..cctor()\r\n --- 内部异常堆栈跟踪结束 ---\r\n 在 Oracle.ManagedDataAccess.Types.TimeStamp.InitializelatestTZversion()\r\n 在 OracleInternal.ServiceObjects.OracleConnectionImpl..cctor()\r\n --- 内部异常堆栈跟踪结束 ---\r\n 在 OracleInternal.ServiceObjects.OracleConnectionImpl..ctor()\r\n --- 内部结束,除了离子堆栈跟踪 ---\r\n"

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

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

                  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 上抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何在 zend db 上构建嵌套选择 下一篇:.NET 5 + Microsoft.Data.SqlClient - 从传输流中收到意外

                  相关文章

                  最新文章

                  <legend id='z5ISN'><style id='z5ISN'><dir id='z5ISN'><q id='z5ISN'></q></dir></style></legend>

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

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