Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215

Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215
通过分析异常堆栈确定异常发生的位置 – 扎老铁
Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215

Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215
Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215
class="post-51763 post type-post status-publish format-standard hentry">

通过分析异常堆栈确定异常发生的位置

1.1.1 通过分析异常堆栈确定异常发生的位置

1.1.1.1 异常信息

红色加粗加下划线的,即为代码调用堆栈的关键信息,通过分析发生异常时代码的调用堆栈,就能基本确定异常发生的位置。

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

 


 

Could not cast or convert
from System.String to System.Type.

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

异常详细信息: System.Exception: Could not cast or convert from System.String to System.Type.

错误: /* “源错误”表示我们的源代码的哪一行在执行时发生了异常。*/
 
 
 
 73:                 return null;
 74:             }
 75:             return JsonConvert.DeserializeObject<T>(str); /* 这表示我们的代码的第 75 行,在调用“JsonConvert.DeserializeObject”方法的时候发生了异常,因为这个方法是第三方类库的方法,因此如果这个调用不存在 JsonConvert 对象为空引用问题的话(即句代码本身没有问题),那么基本可以确定是这个方法内部执行时发生了异常。*/
 76:         }
 77: 


源文件: E:\贵州银行\DB2\BOGZ.OA\src\BOGZ.OA.Data.Mapping\UserTypes\JsonSerializeUserType.cs    : 75

跟踪:

以下是代码调用堆栈信息:
 
/* 最先发生的异常,在 EnsureTypeAssignable 方法中(这是第三方类库的方法信息 ):*/
[Exception: Could not cast or convert from System.String to System.Type.] 
 
/* 这是表示代码执行到这里的时候,发生了异常,下面的方法是相关调用堆栈。*/   Newtonsoft.Json.Utilities.ConvertUtils.EnsureTypeAssignable(Object value, Type initialType, Type targetType) +268
   Newtonsoft.Json.Utilities.ConvertUtils.ConvertOrCast(Object initialValue, CultureInfo culture, Type targetType) +124
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(Object value, Type targetType) +88
 
/* 发生前面的异常后,EnsureType 方法中的 try-catch 异常处理代码捕获了那个异常, 
然后通过 throw new JsonSerializationException(message:异常详细信息,innerException:ex) 
对之前的异常进行了重新包装后抛出了一个新的 JsonSerializationException 异常,且增加了更多的异常说明信息。:*/
[JsonSerializationException: Error converting value "BOGZ.OA.Mentoring, BOGZ.OA.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" to type 'System.Type'.] /* 这是对前面异常进行重新包装并增加更多说明信息后重新抛出异常。*/
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureType(Object value, Type targetType) +219
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) +319
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IWrappedCollection wrappedList, JsonReader reader, String reference, JsonArrayContract contract) +524
   Newtonsoft.Json.Serialization.<>c__DisplayClass1.<CreateAndPopulateList>b__0(IList l, Boolean isTemporaryListReference) +95
   Newtonsoft.Json.Utilities.CollectionUtils.CreateAndPopulateList(Type listType, Action`2 populateList) +544
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateAndPopulateList(JsonReader reader, String reference, JsonArrayContract contract) +101
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String reference) +60
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) +122
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueProperty(JsonReader reader, JsonProperty property, Object target, Boolean gottenCurrentValue, Object currentValue) +194
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonReader reader, Object target) +481
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, String id) +738
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateAndPopulateObject(JsonReader reader, JsonObjectContract contract, String id) +114
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) +929
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) +95
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueNonProperty(JsonReader reader, Type objectType, JsonContract contract) +130
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType) +96
   Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) +47
   Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) +100
   Newtonsoft.Json.JsonConvert.DeserializeObject(String value, JsonSerializerSettings settings) +66
   Newtonsoft.Json.JsonConvert.DeserializeObject(String value) +42
   BOGZ.OA.JsonSerializeUserType`1.NullSafeGet(IDataReader rs, String[] names, Object owner) in E:\贵州银行\DB2\BOGZ.OA\src\BOGZ.OA.Data.Mapping\UserTypes\JsonSerializeUserType.cs:75  /*这一条堆栈和上面的明显不同,这是我们自己写的代码,上面的都是第三方类库, 可以通过方法签名的命名空间以及有没有代码行号来确定是否是我们自己的代码。*/
   NHibernate.Type.CustomType.NullSafeGet(IDataReader rs, String[] names, ISessionImplementor session, Object owner) +17
   NHibernate.Type.AbstractType.Hydrate(IDataReader rs, String[] names, ISessionImplementor session, Object owner) +19
   NHibernate.Persister.Entity.AbstractEntityPersister.Hydrate(IDataReader rs, Object id, Object obj, ILoadable rootLoadable, String[][] suffixedPropertyColumns, Boolean allProperties, ISessionImplementor session) +973
   NHibernate.Loader.Loader.LoadFromResultSet(IDataReader rs, Int32 i, Object obj, String instanceClass, EntityKey key, String rowIdAlias, LockMode lockMode, ILoadable rootPersister, ISessionImplementor session) +279
   NHibernate.Loader.Loader.InstanceNotYetLoaded(IDataReader dr, Int32 i, ILoadable persister, EntityKey key, LockMode lockMode, String rowIdAlias, EntityKey optionalObjectKey, Object optionalObject, IList hydratedObjects, ISessionImplementor session) +139
   NHibernate.Loader.Loader.GetRow(IDataReader rs, ILoadable[] persisters, EntityKey[] keys, Object optionalObject, EntityKey optionalObjectKey, LockMode[] lockModes, IList hydratedObjects, ISessionImplementor session) +296
   NHibernate.Loader.Loader.GetRowFromResultSet(IDataReader resultSet, ISessionImplementor session, QueryParameters queryParameters, LockMode[] lockModeArray, EntityKey optionalObjectKey, IList hydratedObjects, EntityKey[] keys, Boolean returnProxies) +150
   NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +670
   NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +126
   NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +135
 
[GenericADOException: could not execute query
[ select hierarchy0_.[HierarchyId] as column1_17_, hierarchy0_.SortOrder as SortOrder17_, hierarchy0_.Properties as Properties17_, hierarchy0_.HierarchyIdString as Hierarch4_17_, hierarchy0_.Code as Code17_, hierarchy0_.Name as Name17_, hierarchy0_.Department_Id as Department7_17_, hierarchy0_.Parent_Id as Parent8_17_ from oa_Hierarchies hierarchy0_ where hierarchy0_.Name is not null order by hierarchy0_.SortOrder asc ]
[SQL: select hierarchy0_.[HierarchyId] as column1_17_, hierarchy0_.SortOrder as SortOrder17_, hierarchy0_.Properties as Properties17_, hierarchy0_.HierarchyIdString as Hierarch4_17_, hierarchy0_.Code as Code17_, hierarchy0_.Name as Name17_, hierarchy0_.Department_Id as Department7_17_, hierarchy0_.Parent_Id as Parent8_17_ from oa_Hierarchies hierarchy0_ where hierarchy0_.Name is not null order by hierarchy0_.SortOrder asc]] /* 同上,对前面异常进行重新包装,并增加说明信息。*/
   NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +223
   NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) +18
   NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet`1 querySpaces, IType[] resultTypes) +79
   NHibernate.Hql.Ast.ANTLR.Loader.QueryLoader.List(ISessionImplementor session, QueryParameters queryParameters) +51
   NHibernate.Hql.Ast.ANTLR.QueryTranslatorImpl.List(ISessionImplementor session, QueryParameters queryParameters) +231
   NHibernate.Engine.Query.HQLQueryPlan.PerformList(QueryParameters queryParameters, ISessionImplementor session, IList results) +385
   NHibernate.Impl.SessionImpl.List(String query, QueryParameters queryParameters, IList results) +369
   NHibernate.Impl.SessionImpl.List(String query, QueryParameters parameters) +329
   NHibernate.Impl.QueryImpl.List() +158
   BOGZ.OA.HierarchyRepository.GetNameNotNullHierarchies() in E:\贵州银行\DB2\BOGZ.OA\src\BOGZ.OA.Data\HierarchyRepository.cs:33
   BOGZ.OA.HierarchyService.Initialize() in E:\贵州银行\DB2\BOGZ.OA\src\BOGZ.OA.Business\HierarchyService.cs:39
   BOGZ.OA.WeaveHttpApplication.InitDataAndBusinessLayer() in e:\贵州银行\DB2\BOGZ.OA\src\BOGZ.OA.Web\Global.asax.cs:185
   BOGZ.OA.WeaveHttpApplication.Application_Start() in e:\贵州银行\DB2\BOGZ.OA\src\BOGZ.OA.Web\Global.asax.cs:45
 
 
/* 下面的这一坨堆栈可以忽略了,这是  ASP.NET 管道对前面的异常进行的包装,此时异常的包装层次以及比较深了,此时的堆栈也距离异常发生的位置很远了*/
[HttpException (0x80004005): could not execute query
[ select hierarchy0_.[HierarchyId] as column1_17_, hierarchy0_.SortOrder as SortOrder17_, hierarchy0_.Properties as Properties17_, hierarchy0_.HierarchyIdString as Hierarch4_17_, hierarchy0_.Code as Code17_, hierarchy0_.Name as Name17_, hierarchy0_.Department_Id as Department7_17_, hierarchy0_.Parent_Id as Parent8_17_ from oa_Hierarchies hierarchy0_ where hierarchy0_.Name is not null order by hierarchy0_.SortOrder asc ]
[SQL: select hierarchy0_.[HierarchyId] as column1_17_, hierarchy0_.SortOrder as SortOrder17_, hierarchy0_.Properties as Properties17_, hierarchy0_.HierarchyIdString as Hierarch4_17_, hierarchy0_.Code as Code17_, hierarchy0_.Name as Name17_, hierarchy0_.Department_Id as Department7_17_, hierarchy0_.Parent_Id as Parent8_17_ from oa_Hierarchies hierarchy0_ where hierarchy0_.Name is not null order by hierarchy0_.SortOrder asc]]
   System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app) +9966077
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +118
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +352
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
 
[HttpException (0x80004005): could not execute query
[ select hierarchy0_.[HierarchyId] as column1_17_, hierarchy0_.SortOrder as SortOrder17_, hierarchy0_.Properties as Properties17_, hierarchy0_.HierarchyIdString as Hierarch4_17_, hierarchy0_.Code as Code17_, hierarchy0_.Name as Name17_, hierarchy0_.Department_Id as Department7_17_, hierarchy0_.Parent_Id as Parent8_17_ from oa_Hierarchies hierarchy0_ where hierarchy0_.Name is not null order by hierarchy0_.SortOrder asc ]
[SQL: select hierarchy0_.[HierarchyId] as column1_17_, hierarchy0_.SortOrder as SortOrder17_, hierarchy0_.Properties as Properties17_, hierarchy0_.HierarchyIdString as Hierarch4_17_, hierarchy0_.Code as Code17_, hierarchy0_.Name as Name17_, hierarchy0_.Department_Id as Department7_17_, hierarchy0_.Parent_Id as Parent8_17_ from oa_Hierarchies hierarchy0_ where hierarchy0_.Name is not null order by hierarchy0_.SortOrder asc]]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9947444
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +261

 

 


 

版本信息: Microsoft
.NET Framework
版本:4.0.30319;
ASP.NET
版本:4.6.1055.0

 

发表评论

电子邮件地址不会被公开。