• Windows服务异常自动关闭


    一个Windows服务程序,在其他服务器运行都是正常的,今天在新服务器中运行,出现未知异常。

    1.查看系统日志:自定义视图--管理日志
    2.日志内容,比如
    - <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
    - <System>
      <Provider Name=".NET Runtime" /> 
      <EventID Qualifiers="0">1026</EventID> 
      <Level>2</Level> 
      <Task>0</Task> 
      <Keywords>0x80000000000000</Keywords> 
      <TimeCreated SystemTime="2018-10-09T02:29:41.000000000Z" /> 
      <EventRecordID>499672</EventRecordID> 
      <Channel>Application</Channel> 
      <Computer>WIN-N6Q3A4U468A</Computer> 
      <Security /> 
      </System>
    - <EventData>
      <Data>Application: LgWinService.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException Stack: at SNINativeMethodWrapper.SNIClose(IntPtr) at System.Data.SqlClient.SNIHandle.ReleaseHandle() at System.Runtime.InteropServices.SafeHandle.InternalDispose() at System.Runtime.InteropServices.SafeHandle.Dispose(Boolean) at System.Runtime.InteropServices.SafeHandle.Dispose() at System.Data.SqlClient.TdsParserStateObject.Dispose() at System.Data.SqlClient.TdsParser.Disconnect() at System.Data.SqlClient.SqlInternalConnectionTds.LoginFailure() at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(System.Data.ProviderBase.TimeoutTimer, System.Data.SqlClient.SqlConnectionString, System.Data.SqlClient.SqlCredential, System.String, System.Security.SecureString, Boolean) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(System.Data.ProviderBase.DbConnectionPoolIdentity, System.Data.SqlClient.SqlConnectionString, System.Data.SqlClient.SqlCredential, System.Object, System.String, System.Security.SecureString, Boolean, System.Data.SqlClient.SqlConnectionString, System.Data.SqlClient.SessionData) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(System.Data.Common.DbConnectionOptions, System.Data.Common.DbConnectionPoolKey, System.Object, System.Data.ProviderBase.DbConnectionPool, System.Data.Common.DbConnection, System.Data.Common.DbConnectionOptions) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(System.Data.ProviderBase.DbConnectionPool, System.Data.Common.DbConnection, System.Data.Common.DbConnectionOptions, System.Data.Common.DbConnectionPoolKey, System.Data.Common.DbConnectionOptions) at System.Data.ProviderBase.DbConnectionPool.CreateObject(System.Data.Common.DbConnection, System.Data.Common.DbConnectionOptions, System.Data.ProviderBase.DbConnectionInternal) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(System.Data.Common.DbConnection, System.Data.Common.DbConnectionOptions, System.Data.ProviderBase.DbConnectionInternal) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(System.Data.Common.DbConnection, UInt32, Boolean, Boolean, System.Data.Common.DbConnectionOptions, System.Data.ProviderBase.DbConnectionInternal ByRef) at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(System.Data.Common.DbConnection, System.Threading.Tasks.TaskCompletionSource`1<System.Data.ProviderBase.DbConnectionInternal>, System.Data.Common.DbConnectionOptions, System.Data.ProviderBase.DbConnectionInternal ByRef) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(System.Data.Common.DbConnection, System.Threading.Tasks.TaskCompletionSource`1<System.Data.ProviderBase.DbConnectionInternal>, System.Data.Common.DbConnectionOptions, System.Data.ProviderBase.DbConnectionInternal, System.Data.ProviderBase.DbConnectionInternal ByRef) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionFactory, System.Threading.Tasks.TaskCompletionSource`1<System.Data.ProviderBase.DbConnectionInternal>, System.Data.Common.DbConnectionOptions) at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(System.Data.Common.DbConnection, System.Data.ProviderBase.DbConnectionFactory, System.Threading.Tasks.TaskCompletionSource`1<System.Data.ProviderBase.DbConnectionInternal>, System.Data.Common.DbConnectionOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(System.Threading.Tasks.TaskCompletionSource`1<System.Data.ProviderBase.DbConnectionInternal>) at System.Data.SqlClient.SqlConnection.TryOpen(System.Threading.Tasks.TaskCompletionSource`1<System.Data.ProviderBase.DbConnectionInternal>) at System.Data.SqlClient.SqlConnection.Open() at Dos.ORM.Database.CreateConnection(Boolean) at Dos.ORM.Database.ExecuteReader(System.Data.Common.DbCommand) at Dos.ORM.Section.ToDataReader() at Dos.ORM.Section.ToList[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]() at DAL.DBModelDAL.Base_SchoolDAL.GetAllFromBaseView() at BLL.DBModelBLL.Base_DataBLL.InitResSubjectFirst() at LgBigData.WinService.QuartzJob.BaseDataJob.Execute(Quartz.IJobExecutionContext) at Quartz.Core.JobRunShell.Run() at Quartz.Simpl.SimpleThreadPool+WorkerThread.Run() at System.Threading.ThreadHelper.ThreadStart_Context(System.Object) at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object) at System.Threading.ThreadHelper.ThreadStart()</Data> 
      </EventData>
      </Event>

    3.确定问题:​System.Data.SqlClient​的问题。

    微软官方回答:

    https://support.microsoft.com/zh-cn/help/2915689/applications-crash-and-accessviolationexception-exception-occurs-when

    ​https://support.microsoft.com/en-us/help/2915689/applications-crash-and-accessviolationexception-exception-occurs-when

    4.解决方法

    卸载.NET 4.5.1或者升级.NET

    不推荐使用.NET 4.5.1

    Resolution


    To resolve this issue, upgrade the .NET Framework 4.5.1 to the Microsoft .NET Framework 4.5.2 .
  • 相关阅读:
    学习 JS 内容知识点与个人感悟【2】
    学习两天hml的感悟
    编程一星期感悟(上)
    java基础及练习题
    java基础程序代码及Scanner和Random
    java中Random和Scanner及其循环语句
    java语言及数据类型
    SQL含义+单行函数
    DTL+数据字典+序列、索引、视图
    sql plus及SQL语句
  • 原文地址:https://www.cnblogs.com/charles-jiang/p/9759527.html
Copyright © 2020-2023  润新知