Hi,
Heres the plan :-
Transform some XML via XSLT and save the resulting HTML to a file in a certain folder.
Write a printing service that wraps a FileSystemWatcher monitoring the above folder for new HTML files.
Print the newly created HTML file.
If I run the code - contained in the sub below - in a normal .NET app it works fine and the HTML is sent to the printer. But when I implement it as a service as shown in the sub below all you get is a Windows Alert sound ( and obviously no message as it is a service nor any exception thrown. At first I thought it was because the thread had not finished processing before it was discarded but it isn't.
Any thoughts anybody? Cheers.
Private Sub SpoolFileSystemWatcher_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles SpoolFileSystemWatcher.Created
Try
Dim x As StreamReader = File.OpenText(e.FullPath)
Dim y As String = x.ReadToEnd()
x.Close()
test = New SHDocVw.InternetExplorerClass()
test.Navigate("about:blank"
test.Document.body.innerhtml = Trim
test.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER)
Dim n As Integer
For n = 1 To 3000000
Next
Catch ex As Exception
If EventLog.SourceExists("spool" = False Then
EventLog.CreateEventSource("spool", "application"
End If
System.Diagnostics.EventLog.WriteEntry("spool", ex.Message, EventLogEntryType.Information)
End Try
End Sub
Heres the plan :-
Transform some XML via XSLT and save the resulting HTML to a file in a certain folder.
Write a printing service that wraps a FileSystemWatcher monitoring the above folder for new HTML files.
Print the newly created HTML file.
If I run the code - contained in the sub below - in a normal .NET app it works fine and the HTML is sent to the printer. But when I implement it as a service as shown in the sub below all you get is a Windows Alert sound ( and obviously no message as it is a service nor any exception thrown. At first I thought it was because the thread had not finished processing before it was discarded but it isn't.
Any thoughts anybody? Cheers.
Private Sub SpoolFileSystemWatcher_Created(ByVal sender As Object, ByVal e As System.IO.FileSystemEventArgs) Handles SpoolFileSystemWatcher.Created
Try
Dim x As StreamReader = File.OpenText(e.FullPath)
Dim y As String = x.ReadToEnd()
x.Close()
test = New SHDocVw.InternetExplorerClass()
test.Navigate("about:blank"
test.Document.body.innerhtml = Trim
test.ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER)
Dim n As Integer
For n = 1 To 3000000
Next
Catch ex As Exception
If EventLog.SourceExists("spool" = False Then
EventLog.CreateEventSource("spool", "application"
End If
System.Diagnostics.EventLog.WriteEntry("spool", ex.Message, EventLogEntryType.Information)
End Try
End Sub