Turkish character problem in sql queries when windows service is running

111 Views Asked by At

When windows server 2019 comes to the desktop, when the application.exe is run, the sql connects and runs smoothly. But when I write this application as a service, I have a Turkish character problem when the application.exe runs. It shows letters like "İŞıö.." differently. The working logic of the services is different from running the application by double-clicking on the desktop and running it with the service. how can i solve this problem. related service code

Imports System.Timers

Public Class Service1
    Dim proc As Process
    Dim tmr As Timer

    Protected Overrides Sub OnStart(ByVal args() As String)
        Try
            WriteToFile("SQL wait")
            tmr = New Timer
            tmr.Interval = 30000
            AddHandler tmr.Elapsed, AddressOf SqlRun
            tmr.Enabled = True
        Catch ex As Exception
            tmr.Enabled = False
            WriteToFile("err " & ex.Message)
        End Try
    End Sub

    Private Sub SqlRun(sender As Object, e As ElapsedEventArgs)
        tmr.Enabled = False
        Try
            WriteToFile("app run")
            proc = New Process()
            proc = Process.Start("C:\app.exe")
            WriteToFile("app run. ID " & proc.Id)
        Catch ex As Exception
            WriteToFile("app err " + ex.Message + ex.StackTrace)
        End Try
    End Sub

    Protected Overrides Sub OnStop()
        tmr.Enabled = False
        WriteToFile("app end")
        proc = New Process
        proc = Process.Start("taskkill", "/f /im app.exe")
        WriteToFile("app end. ID " & proc.Id)
    End Sub

    Private Sub WriteToFile(text As String)
        text += " " & Format(DateTime.Now, "dd/MM/yyyy hh:mm:ss")

        Using writer As New IO.StreamWriter(path, True)
            writer.WriteLine(text)
            writer.Close()
        End Using
    End Sub
End Class
0

There are 0 best solutions below