Im trying to print a word document through my software. the program works as a normal application but when the same code is used in a windows service the service freezes at the creation of the word.application.
VB.NET:
' this is the line that freezes the service.
Dim wordApp As New Microsoft.Office.Interop.Word.Application
Dim wordDoc As Microsoft.Office.Interop.Word.Document
Dim xmlData As IO.MemoryStream = New IO.MemoryStream
Dim fs As IO.FileStream
fs = New FileStream("c:\a.xml", FileMode.Open)
Dim xmlReader As StreamReader = New StreamReader(fs)
wordDoc = wordApp.Documents.Add()
wordDoc.Range.Text = xmlReader.ReadToEnd
wordDoc.PrintOut()
wordDoc.Close()
wordDoc = Nothing
wordApp.Quit()
wordApp = Nothing