windows - .net ansøgning går i stykker uden en fejl

Indlæg af Hanne Mølgaard Plasc

Problem



Jeg skrev en ansøgning i VB.Net og på en eller anden måde styrter den uden en grund, for eksempel kører jeg den, den startede succesfuldt, og efter at have holdt sig ikke aktiv i 10 eller flere minutter krasjer den uden nogen undtagelse, og Visual Studio fortæller mig, at processen skiftet til stop mode og applikationen blev lukket.


Min hovedkode er ikke en loop, bortset fra at en timer altid er aktiveret med 100ms periode, tror jeg ikke, det er et problem. Det sjove er, at det tidspunkt, hvor processen går ned, varierer.


Jeg forsøgte min ansøgning på to Win10-maskiner. På en af ​​dem kolliderer det slet ikke, og på den anden går der nogle gange i stykker. Og jeg prøvede på Win7, krasjer sker regelmæssigt efter 20 min. - Windows siger 'Programmet svarer ikke, vi lukker appen'. Så hvorfor det viser ikke nogen undtagelser i fejlfindingstilstanden til VS17, jeg har også tændt alle undtagelser i fejlfindingsmenuen.
først er net runtime log og anden er applikation log:


Имя журнала:   Application
Источник:      .NET Runtime
Дата:          28.04.2018 18:40:02
Код события:   1026
Категория задачи:Отсутствует
Уровень:       Ошибка
Ключевые слова:Классический
Пользователь:  Н/Д
Компьютер:     HV-service-ПК
Описание:
Application: SD CARD Car Master [beta].exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ObjectDisposedException
Stack:
   at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean ByRef)
   at System.StubHelpers.StubHelpers.SafeHandleAddRef(System.Runtime.InteropServices.SafeHandle, Boolean ByRef)
   at Microsoft.Win32.UnsafeNativeMethods.GetOverlappedResult(Microsoft.Win32.SafeHandles.SafeFileHandle, System.Threading.NativeOverlapped*, Int32 ByRef, Boolean)
   at System.IO.Ports.SerialStream+EventLoopRunner.WaitForCommEvent()
   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()

Xml события:
<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-04-28T07:40:02.000000000Z" />
    <EventRecordID>533</EventRecordID>
    <Channel>Application</Channel>
    <Computer>HV-service-ПК</Computer>
    <Security />
  </System>
  <EventData>
    <Data>Application: SD CARD Car Master [beta].exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ObjectDisposedException
Stack:
   at System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean ByRef)
   at System.StubHelpers.StubHelpers.SafeHandleAddRef(System.Runtime.InteropServices.SafeHandle, Boolean ByRef)
   at Microsoft.Win32.UnsafeNativeMethods.GetOverlappedResult(Microsoft.Win32.SafeHandles.SafeFileHandle, System.Threading.NativeOverlapped*, Int32 ByRef, Boolean)
   at System.IO.Ports.SerialStream+EventLoopRunner.WaitForCommEvent()
   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>

Имя журнала:   Application
Источник:      Application Error
Дата:          28.04.2018 18:31:18
Код события:   1000
Категория задачи:(100)
Уровень:       Ошибка
Ключевые слова:Классический
Пользователь:  Н/Д
Компьютер:     HV-service-ПК
Описание:
Имя сбойного приложения: SD CARD Car Master [beta].exe, версия: 1.0.0.0, отметка времени: 0x5ae2a828
Имя сбойного модуля: KERNELBASE.dll, версия: 6.1.7601.17514, отметка времени 0x4ce7b8f0
Код исключения: 0xe0434352
Смещение ошибки: 0x0000b760
Идентификатор сбойного процесса: 0xc9c
Время запуска сбойного приложения: 0x01d3dec2dcbdc3d0
Путь сбойного приложения: C:UsersHV-serviceDesktopSD CARD Car Master [beta].exe
Путь сбойного модуля: C:Windowssystem32KERNELBASE.dll
Код отчета: 238f20b0-4ab6-11e8-b866-001b3822ff72
Xml события:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Application Error" />
    <EventID Qualifiers="0">1000</EventID>
    <Level>2</Level>
    <Task>100</Task>
    <Keywords>0x80000000000000</Keywords>
    <TimeCreated SystemTime="2018-04-28T07:31:18.000000000Z" />
    <EventRecordID>531</EventRecordID>
    <Channel>Application</Channel>
    <Computer>HV-service-ПК</Computer>
    <Security />
  </System>
  <EventData>
    <Data>SD CARD Car Master [beta].exe</Data>
    <Data>1.0.0.0</Data>
    <Data>5ae2a828</Data>
    <Data>KERNELBASE.dll</Data>
    <Data>6.1.7601.17514</Data>
    <Data>4ce7b8f0</Data>
    <Data>e0434352</Data>
    <Data>0000b760</Data>
    <Data>c9c</Data>
    <Data>01d3dec2dcbdc3d0</Data>
    <Data>C:UsersHV-serviceDesktopSD CARD Car Master [beta].exe</Data>
    <Data>C:Windowssystem32KERNELBASE.dll</Data>
    <Data>238f20b0-4ab6-11e8-b866-001b3822ff72</Data>
  </EventData>
</Event>


Opdatering: Jeg har bemærket, at problemet i seriel portens autoconnect-kode:


  Private Sub Form1\_Load(sender As Object, e As EventArgs) Handles MyBase.Load

        Connected = False
   autoconnect()
    End Sub
 Private Sub autoconnect()

        For Each sp As String In My.Computer.Ports.SerialPortNames
            Try
                spObj = New SerialPort(sp, 115200, Parity.None, 8, StopBits.One)
                spObj.ReadTimeout = 5000
                '    spObj.ReceivedBytesThreshold = 6
                spObj.WriteTimeout = 5000
                spObj.Open()

                Dim ListeningWatch As New Stopwatch
                Dim serialMessage As String

                Dim BytesToSend(1) As Byte
                Dim OutBuffer
                BytesToSend(0) = Hex(99)             ' call Dump eeprom (44)
                BytesToSend(1) = 0                   'dummy
                OutBuffer = BytesToSend

                ' Bytes are outputted in the order of their Index Number(Index)!

                spObj.Write(OutBuffer, 0, OutBuffer.length)

                ListeningWatch.Start()
                While ListeningWatch.ElapsedMilliseconds < 5000 And ListeningWatch.IsRunning
                    serialMessage = spObj.ReadExisting()
                    'RichTextBox1.Text = serialMessage
                    If serialMessage.Contains("000001020") And serialMessage.Length = 12 Then
                        ListeningWatch.Stop()

                        Connected = True
                        Timer1.Enabled = False
                        DeviceStatus.Text = "SN: " & serialMessage                       
                        Exit For
                    End If
                End While
            Catch ex As Exception
                spObj.Dispose()
            End Try
        Next
        If Connected = False Then
            DeviceStatus.Text = "SN: Not connected"
        End If
    End Sub

Bedste reference