异常:操作可能会破坏运行时稳定性

“/”应用程序中的服务器错误。


操作可能会破坏运行时稳定性。

说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 

异常详细信息: System.Security.VerificationException: 操作可能会破坏运行时稳定性。

源错误: 

行 2439:                toThrow = new DataException(ex.Message, ex);
行 2440:            }
行 2441:            throw toThrow;
行 2442:        }
行 2443:        private static void EmitInt32(ILGenerator il, int value)


源文件: G:647VS项目双英webDapperSqlMapper.cs    行: 2441 

堆栈跟踪: 

[VerificationException: 操作可能会破坏运行时稳定性。]
   Deserialized3231e7d-b930-47e9-a62d-86a2aa2a0d26(IDataReader ) +452

[DataException: Error parsing column 3 (IsSectionDisabled=可用 - String)]
   Dapper.SqlMapper.ThrowDataException(Exception ex, Int32 index, IDataReader reader) in G:647VS项目双英webDapperSqlMapper.cs:2441
   Deserialized3231e7d-b930-47e9-a62d-86a2aa2a0d26(IDataReader ) +495
   Dapper.<QueryInternal>d__d`1.MoveNext() in G:647VS项目双英webDapperSqlMapper.cs:854
   System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) +327
   System.Linq.Enumerable.ToList(IEnumerable`1 source) +58
   Dapper.SqlMapper.Query(IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType) in G:647VS项目双英webDapperSqlMapper.cs:773
   Etrol.Web.SQLSeverDal.FoundationData.ProductionData.ProductionLineDal.GetWarehouse() in G:647VS项目双英webDalEtrol.Web.SQLSeverDalFoundationDataProductionDataProductionLineDal.cs:300
   Etrol.Web.Bll.FoundationData.ProductionData.ProductionLineBll.GetWarehouse() in G:647VS项目双英webBllEtrol.Web.BllFoundationDataProductionDataProductionLineBll.cs:116
   Etrol.Web.ProductionFoundation.Controllers.ProductionLineController.GetWarehouse() in G:647VS项目双英webPluginsEtrol.Web.ProductionFoundationControllersProductionLineController.cs:189

最后查询出问题:页面上绑定的model的字段是字符串类型的,但是对应的该字段在数据库中该字段是int型的。

强制转换不成功导致此错误。

原文地址:https://www.cnblogs.com/abc8023/p/3580021.html