Death in production...

WellsCarrie

Well-known member
Joined
Jul 12, 2005
Messages
95
Location
Arkansas
Programming Experience
5-10
Ok my code works great if you have debug points established in it. But should you stop the debugging and just try to run it as production code is sits and does nothing.

Perhapse one of you can take a look and see what I've done to cause this.

VB.NET:
Dim ohioConn As New OracleConnection("Data Source=Ohio.world;User Id=me;Password=pw;")
    Dim ohioCmd As New OracleCommand
    Dim reader As OracleDataReader
    Dim str As String
    Dim sb As New System.Text.StringBuilder
    Dim WordApp As New Word.Application
    Dim wdShape As Word.InlineShape
    Protected Overrides Sub OnStart(ByVal args() As String)
        ' Add code here to start your service. This method should set things
        ' in motion so your service can do its work.
        If Not EL1.SourceExists("DragTag") Then
            EL1.CreateEventSource("DragTag", "Drag Tag Log") ' Create Log
        End If
        EL1.Source = "DragTag"
        'EL1.WriteEntry("DragTag", "Starting Drag Tag File Watcher. ")
        WordApp.Visible = True
        WordApp.WindowState = Word.WdWindowState.wdWindowStateNormal '.wdWindowStateMinimize
        'WordApp.Documents.Open("c:\WatchFiles\Template\DragTag.dot")
        Timer1.Interval = 15000
        Timer1.Enabled = True
    End Sub
    Protected Overrides Sub OnStop()
        ' Add code here to perform any tear-down necessary to stop your service.
        '//Release class level objects to garbage collector
        reader.Dispose()
        ohioCmd.Dispose()
        ohioConn.Dispose()
        str = Nothing
        sb = Nothing
        WordApp.Documents.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
        WordApp.Quit()
        WordApp = Nothing
        wdShape = Nothing
        Dim myProcesses() As Process
        Dim myProcess As Process
        ' Returns array containing all instances of "WINWORD".
        myProcesses = Process.GetProcessesByName("WINWORD")
        For Each myProcess In myProcesses
            myProcess.Kill()
        Next
        myProcesses = Nothing
        myProcess = Nothing
        If EL1.SourceExists("DragTag") Then
            EL1.DeleteEventSource("DragTag") 'Delete Log
        End If
    End Sub
    Public Sub CheckForFiles()
        Dim di As New IO.DirectoryInfo("c:\WatchFiles\")
        Dim fiGetFiles As IO.FileInfo() = di.GetFiles("*.csv")
        Dim fi As IO.FileInfo
        
        Try
            
            For Each fi In fiGetFiles
                DoProcess(fi.Name)
            Next
        Catch ex As Exception
            sb.Remove(0, sb.Length)
            sb.Append("Sub CheckForFiles - ")
            sb.Append(ex.Source)
            sb.Append(" - ")
            sb.Append(ex.Message)
            EL1.WriteEntry("DragTag", sb.ToString())
        Finally
            '// Clean up our mess.
            di = Nothing
            fiGetFiles = Nothing
            fi = Nothing
        End Try
    End Sub
    Private Sub DoProcess(ByVal file As String)
        Dim oFile As IO.File
        Dim oRead As IO.StreamReader
        Dim bol As Boolean = True
        Try
            'Open the file for read
            oRead = oFile.OpenText("c:\WatchFiles\" & file)
            If oRead.Peek() <> -1 Then
                While oRead.Peek() <> -1
                    oRead.ReadLine()
                    If bol Then
                        PrintDocument(BuildData(oRead.ReadLine()))
                        bol = False
                    End If
                End While
            End If
            oRead.Close()
            ' Send file onto next processing point
            If oFile.Exists("c:\WatchFiles\" & file) Then
                oFile.Move("c:\WatchFiles\" & file, "c:\WatchFiles\ProcessedCSVs\" & file)
            End If
        Catch ex As Exception
            sb.Remove(0, sb.Length)
            sb.Append("Sub DoProcess- ")
            sb.Append(ex.Source)
            sb.Append(" - ")
            sb.Append(ex.Message)
            EL1.WriteEntry("DragTag", sb.ToString())
        Finally
            oFile = Nothing
            oRead = Nothing
            bol = Nothing
            sb = Nothing
        End Try
    End Sub
    Private Function BuildData(ByVal Value As String) As String()
        Dim info As String()
        Dim theInfo(20) As String
        Dim SearchNumber As String
        Dim temp As String = ""
        Try
            info = Split(Value, ",")
            temp = Replace(Trim(info(65)), """", "") & " " & _
                         Replace(Trim(info(66)), """", "") & " " & _
                         Replace(Trim(info(67)), """", "") & " " & _
                         Replace(Trim(info(68)), """", "") & " " & _
                         Replace(Trim(info(69)), """", "") & " " & _
                         Replace(Trim(info(70)), """", "") & ", " & _
                         Replace(Trim(info(71)), """", "") & " " & _
                         Replace(Trim(info(72)), """", "")
            theInfo(0) = Replace(Trim(temp), "  ", " ") 'DockAddress
            temp = ""
            theInfo(1) = Replace(Trim(info(9)), """", "") 'ShipName
            theInfo(2) = Replace(Trim(info(11)), """", "") 'ShipAddress
            theInfo(3) = Replace(Trim(info(14)), """", "") & ", " & _
                            Replace(Trim(info(15)), """", "")         'ShipCityState
            theInfo(4) = Replace(Trim(info(16)), """", "") 'ShipZip
            If Replace(Trim(info(55)), """", "") = "WMIT" Then
                temp = Replace(Trim(info(12)), """", "")
                theInfo(5) = "DC#" 'DCLable
                theInfo(6) = "TYPE" 'TypeLable
                theInfo(7) = "DEPT" 'Deptlable
                theInfo(8) = Mid(temp, 1, 5) 'ShipDCNum
                theInfo(9) = Mid(temp, 6, 4) 'ShipType
                theInfo(10) = Mid(temp, 10, 5) 'ShipDept
                theInfo(14) = "WMIT" 'WMCode
            Else
                theInfo(5) = "" 'DCLable
                theInfo(6) = "" 'TypeLable
                theInfo(7) = "" 'Deptlable
                theInfo(8) = "" 'ShipDCNum
                theInfo(9) = "" 'ShipType
                theInfo(10) = "" 'ShipDept
                theInfo(14) = "" 'WMCode
            End If
            theInfo(11) = Replace(Trim(info(3)), """", "") 'ShipSKU
            theInfo(12) = "" 'TMPArrival 
            theInfo(13) = Trim(Replace(info(30), """", "")) 'Carrier
            theInfo(15) = Trim(Replace(info(52), """", "")) 'CustomerPO
            theInfo(16) = Trim(Replace(info(44), """", "")) 'OrderNumber
            temp = Trim(Replace(info(28), """", ""))
            temp = CType((Math.Round(CType(temp, Double), 0) + 62), String)
            theInfo(17) = CType(temp, String)  'PalletWeight
            temp = Replace(info(35), """", "")
            If Len(Trim(temp)) = 0 Or Trim(temp) = "0" Then
                theInfo(18) = Trim(Replace(info(33), """", "")) 'MastContNum
            Else
                theInfo(18) = Trim(Replace(info(35), """", "")) 'MastContNum
            End If
            theInfo(19) = "" 'PrinterName
           
            temp = Replace(info(44), """", "")
            'System.Diagnostics.Debugger.Break()
            
            str = "SELECT sch_shp_dt FROM [EMAIL="outordhdr@main"]outordhdr@main[/EMAIL] " & _
                  "WHERE ord_num = '" & Trim(temp) & _
                  "' UNION " & _
                  "SELECT sch_shp_dt FROM [EMAIL="outordhdr@deal"]outordhdr@deal[/EMAIL] " & _
                  "WHERE ord_num = '" & Trim(temp) & "'"
            'System.Diagnostics.Debugger.Break()
            ohioConn.Open()
            ohioCmd.Connection = ohioConn
            ohioCmd.CommandText = str
            reader = ohioCmd.ExecuteReader()
            If reader.HasRows() Then
                While reader.Read()
                    If Len(Trim(CType(reader(0), String))) > 0 Then
                        theInfo(12) = CType(reader(0), String) 'TMPArrival
                    End If
                End While
            Else
                theInfo(12) = "" 'TMPArrival
            End If
            reader.Close()
            str = "SELECT printer_name FROM drag_tag_printers_tbl " & _
                  "WHERE printer = " & Replace(Trim(info(1)), """", "")
            ohioCmd.Connection = ohioConn
            ohioCmd.CommandText = str
            reader = ohioCmd.ExecuteReader()
            If reader.HasRows() Then
                While reader.Read()
                    theInfo(19) = CType(reader(0), String) 'PrinterName
                End While
            Else
                theInfo(19) = "nlrmis1 on may_printserver" 'PrinterName
            End If
            reader.Close()
        Catch ex As Exception
            sb.Remove(0, sb.Length)
            sb.Append("Funciton BuildData - ")
            sb.Append(ex.Source)
            sb.Append(" - ")
            sb.Append(ex.Message)
            EL1.WriteEntry("DragTag", sb.ToString())
        Finally
            If ohioConn.State = ConnectionState.Open Then
                ohioConn.Close()
            End If
        End Try
        Return theInfo
    End Function

    Private Sub PrintDocument(ByVal theInfo As String())
        Try
            'System.Diagnostics.Debugger.Break()
            'Send info for printing
            With WordApp
                
                .Documents.Open("c:\WatchFiles\Template\DragTag.dot", False)
                'System.Diagnostics.Debugger.Break()
                .ActiveDocument.Bookmarks.Item("DockAddress").Select()
                .Selection.Text = theInfo(0)
                .ActiveDocument.Bookmarks.Item("ShipName").Select()
                .Selection.Text = theInfo(1)
                .ActiveDocument.Bookmarks.Item("ShipAddress").Select()
                .Selection.Text = theInfo(2)
                .ActiveDocument.Bookmarks.Item("ShipCityState").Select()
                .Selection.Text = theInfo(3)
                .ActiveDocument.Bookmarks.Item("ShipZip").Select()
                .Selection.Text = theInfo(4)
                .ActiveDocument.Bookmarks.Item("DCLable").Select()
                .Selection.Text = theInfo(5)
                .ActiveDocument.Bookmarks.Item("TypeLable").Select()
                .Selection.Text = theInfo(6)
                .ActiveDocument.Bookmarks.Item("DeptLable").Select()
                .Selection.Text = theInfo(7)
                .ActiveDocument.Bookmarks.Item("ShipDCNum").Select()
                .Selection.Text = theInfo(8)
                .ActiveDocument.Bookmarks.Item("ShipType").Select()
                .Selection.Text = theInfo(9)
                .ActiveDocument.Bookmarks.Item("ShipDept").Select()
                .Selection.Text = theInfo(10)
                .ActiveDocument.Bookmarks.Item("ShipSku").Select()
                .Selection.Text = theInfo(11)
                .ActiveDocument.Bookmarks.Item("ArrivalDate").Select()
                .Selection.Text = theInfo(12)
                .ActiveDocument.Bookmarks.Item("Carrier").Select()
                .Selection.Text = theInfo(13)
                .ActiveDocument.Bookmarks.Item("WMCode").Select()
                .Selection.Text = Trim(theInfo(14))
                .ActiveDocument.Bookmarks.Item("CustomerPO").Select()
                .Selection.Text = theInfo(15)
                .ActiveDocument.Bookmarks.Item("OrderNum").Select()
                .Selection.Text = theInfo(16)
                .ActiveDocument.Bookmarks.Item("PalletWeight").Select()
                .Selection.Text = theInfo(17)
                '//Write Master Container Number as Barcode
                For Each wdShape In .ActiveDocument.InlineShapes
                    With wdShape.OLEFormat.Object
                        If (StrComp(.Name, "TBarCode31", vbTextCompare) = 0) Then
                            .LicenseMe("Maybelline, Inc.", 3, 1, "CE7151AB", 5)
                            .Text = theInfo(18)
                            If (Len(Trim(theInfo(18))) = 0) Then
                                .BarCode = 0
                            Else
                                .BarCode = 33
                            End If
                            Exit For
                        End If
                    End With
                Next wdShape
                'Print file
                .WordBasic.FilePrintSetup(Printer:=theInfo(19), DoNotSetAsSysDefault:=1)
                .PrintOut(Copies:=2, BackGround:=True)
                'Wait for document to print
                Do While .BackgroundPrintingStatus > 0
                    'Loop until documents have printed then continue
                Loop
                .Documents.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
            End With
        Catch ex As Exception
            sb.Remove(0, sb.Length)
            sb.Append("Sub PrintDocument - ")
            sb.Append(ex.Source)
            sb.Append(" - ")
            sb.Append(ex.Message)
            EL1.WriteEntry("DragTag", sb.ToString())
        End Try
    End Sub
    Private Sub Timer1_Elapsed(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
        'Pause timer
        Timer1.Enabled = False
        CheckForFiles()
        Timer1.Enabled = True
    End Sub

I'm really at a loss...
Oh and why doesn't my "WINWORD" exe ever close? Even running through the OnStop doesn't kill it. it just sits in the processes until I reboot.
 
I'd be interested to find out what a solution to this would be. I'm running into a very similar program with my code...basically, if I compile the service in Debug mode and then attach to the running process, it behaves as expected. But if I compile in release mode, or if I don't attach to the process, I get no response from the service. So you know what you're looking at, this is a small program that prevents us from having to configure each client installation of our main program. This service is intended to run on the server, and pass the necessary information to a client when the service recieves a UDP broadcast packet from the client, requesting the configuration info.

VB.NET:
[SIZE=2][COLOR=#0000ff]
Public[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] Service1
[/SIZE][SIZE=2][COLOR=#008000]'Private udp As Net.Sockets.UdpClient
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Protected[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Overrides[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] OnStart([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] args() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#008000]' Start Listener Thread
[/COLOR][/SIZE][SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] listenerThread [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Threading.Thread = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Threading.Thread([/SIZE][SIZE=2][COLOR=#0000ff]AddressOf[/COLOR][/SIZE][SIZE=2] ListenForAppRequests)
listenerThread.Start()
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Protected[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Overrides[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] OnStop()
[/SIZE][SIZE=2][COLOR=#008000]' Nothing that needs to be done here...if it wants to stop, let it stop
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ListenForAppRequests()
Debug.Print([/SIZE][SIZE=2][COLOR=#800000]"Listener Started..."[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] udp [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Net.Sockets.UdpClient
[/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2]udp = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Net.Sockets.UdpClient(5074)
[/SIZE][SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception
Debug.Print(ex.Message)
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'udp.ExclusiveAddressUse = False
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'udp.EnableBroadcast = True
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] remoteEP [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Net.IPEndPoint
[/SIZE][SIZE=2][COLOR=#0000ff]Do
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] newPacket [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Byte[/COLOR][/SIZE][SIZE=2]() = udp.Receive(remoteEP)
Debug.Print(System.Text.Encoding.ASCII.GetString(newPacket))
[/SIZE][SIZE=2][COLOR=#0000ff]Call[/COLOR][/SIZE][SIZE=2] ProcessRequest(remoteEP, newPacket, udp)
[/SIZE][SIZE=2][COLOR=#0000ff]Loop
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] ProcessRequest([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] remoteEP [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Net.IPEndPoint, [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] udpPacket [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Byte[/COLOR][/SIZE][SIZE=2](), [/SIZE][SIZE=2][COLOR=#0000ff]ByRef[/COLOR][/SIZE][SIZE=2] udp [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Net.Sockets.UdpClient)
[/SIZE][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][SIZE=2].Application.Log.WriteEntry([/SIZE][SIZE=2][COLOR=#800000]"acServerControl: In ProcessRequest"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] udpPak [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = System.Text.Encoding.ASCII.GetString(udpPacket)
Debug.Print(udpPak)
[/SIZE][SIZE=2][COLOR=#0000ff]Select[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] udpPak.Substring(0, 5)
[/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#800000]"FSVR-"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'packet prefix recognized - find application server
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'determine which app they need
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'load list of applications and necessary connection strings from XML file
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] dsApplications [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] DataSet
[/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2]dsApplications.ReadXml([/SIZE][SIZE=2][COLOR=#0000ff]My[/COLOR][/SIZE][SIZE=2].Application.Info.DirectoryPath & [/SIZE][SIZE=2][COLOR=#800000]"\apps.xml"[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]Catch[/COLOR][/SIZE][SIZE=2] ex [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Exception
[/SIZE][SIZE=2][COLOR=#0000ff]Throw[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Exception([/SIZE][SIZE=2][COLOR=#800000]"An error occurred while reading the list of supported applications."[/COLOR][/SIZE][SIZE=2])
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Try
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][SIZE=2] dr [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Data.DataRow [/SIZE][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][SIZE=2] dsApplications.Tables(0).Rows
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] dr.Item([/SIZE][SIZE=2][COLOR=#800000]"code"[/COLOR][/SIZE][SIZE=2]) = Microsoft.VisualBasic.Right(udpPak, Len(udpPak) - 5) [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2]SendData([/SIZE][SIZE=2][COLOR=#800000]"INFO-"[/COLOR][/SIZE][SIZE=2] & dr.Item([/SIZE][SIZE=2][COLOR=#800000]"connstring"[/COLOR][/SIZE][SIZE=2]), remoteEP, udp)
[/SIZE][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Next
[/COLOR][/SIZE][SIZE=2]SendData([/SIZE][SIZE=2][COLOR=#800000]"ERR-BADAPP"[/COLOR][/SIZE][SIZE=2], remoteEP, udp)
[/SIZE][SIZE=2][COLOR=#0000ff]Case[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Else
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#008000]'unknown packet, ignore
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Select
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] SendData([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] DataToSend [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] remoteEP [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Net.IPEndPoint, [/SIZE][SIZE=2][COLOR=#0000ff]ByRef[/COLOR][/SIZE][SIZE=2] udpaa [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Net.Sockets.UdpClient)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] udp [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] System.Net.Sockets.UdpClient()
udp.ExclusiveAddressUse = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2]Debug.Print([/SIZE][SIZE=2][COLOR=#800000]"Sending: "[/COLOR][/SIZE][SIZE=2] & DataToSend)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] destEP [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Net.IPEndPoint(remoteEP.Address, 5073)
Debug.Print([/SIZE][SIZE=2][COLOR=#800000]"Destination: "[/COLOR][/SIZE][SIZE=2] & destEP.Address.ToString & [/SIZE][SIZE=2][COLOR=#800000]":"[/COLOR][/SIZE][SIZE=2] & destEP.Port)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] _info() [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Byte[/COLOR][/SIZE][SIZE=2] = System.Text.Encoding.UTF8.GetBytes(DataToSend)
[/SIZE][SIZE=2][COLOR=#008000]'Dim udp As Net.Sockets.UdpClient = New Net.Sockets.UdpClient(5074)
[/COLOR][/SIZE][SIZE=2]udp.Send(_info, _info.Length, destEP)
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Class
[/COLOR][/SIZE]
 
Nate it apears to me your listener only exists for the OnStart Sub. So Once your on start has finished there is Nothing telling it to keep "Listening".
I'm not positive that is Your actual problem but you might want to add a system.timers.timer to your service and have it kick off your listener every 15 seconds or so and see if that helps you. Again not positive that is your real problem. But it couldn't hurt to try.
 
WellsCarrie,
That was exactly the problem...I moved the declaration of the System.Threading.Thread outside of the OnStart routine, and it immediately started working like I was expecting it to. For some reason, I'm guessing since it was working in debugging mode, I didn't even think about the scope of the variable. Thanks for your help!
 
Back
Top