Hello.
I have a windows service file, that runs fine through my test application (console program). I then placed my code into a windows service. After installing the service, I check the event logs and I keep seeing this error in the event log, which seems to be preventing further processing:
"Cannot create ActiveX component"
What am I doing wrong. I changed the settings on the application (through the services manager), so that the app uses my local logon information (instead of local)...
hmmm...any suggestions? I thought activex was just for web pages...and I am writing a service.
the service file pulls records from 2 tables and then exports those expired records to an excel document. the excel document is then emailed.
is the problem from my service or a setting?
thank you.
==Code from service=============
Imports System
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlTypes
Imports System.Data.SqlClient
Imports System.Diagnostics
Imports System.Net
Imports System.Net.Mail
Imports System.ServiceProcess
Imports Pulls.showDropFiles
Imports Pulls.copyDropFiles
Imports Pulls.removeExpRecords
Imports Pulls.excelExport
Public Class BETCheckFiles
Public Sub New()
MyBase.new()
InitializeComponent()
If Not System.Diagnostics.EventLog.SourceExists("Expired Records") Then
System.Diagnostics.EventLog.CreateEventSource("Expired Records", "Expired Search Log")
EventLog1.Source = "Expired Records"
EventLog1.Log = "Expired Search Log"
End If
End Sub
Protected Overrides Sub OnStart(ByVal args() As String)
Try
If Pulls.getRecords.Rows.Count.ToString = 0 Then
EventLog.WriteEntry("As of " & Today & " There are no files for this week.")
Else
'**begin to count expired records
EventLog.WriteEntry(Today & " There are " & getRecords.Rows.Count.ToString & " expired records for this week.")
'**insertExpRecords() function will copy records to logging table and write process to log
insertExpRecords()
EventLog.WriteEntry(Today & " Success! Files Copied to logging table.")
'**export records to excel log file
exportrecs()
removeRecords()
EventLog.WriteEntry(Today & " Success! Log of records emailed and the expired records for this week have been removed from their respective tables.")
End If
Catch ex As Exception
EventLog.WriteEntry(ex.Message)
End Try
'send email
DropFilesEmails()
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
EventLog.WriteEntry(Today & "All files swept and the Service Stopped.")
End Sub
Public Sub DropFilesEmails()
'Create the mail message
Dim mail As New MailMessage()
'set the address
mail.From = New MailAddress("myname@test.net")
mail.To.Add("myname@test.net")
mail.IsBodyHtml = True
'create the content
mail.Subject = "Expired records Log Transaction for " & Today
'message body should be a formatted excel document (the html does not work here)
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(Today & " Attached you will find the log file for the Expiration Service. " & getRecords().Rows.Count.ToString & " records were logged for removal.")
mail.AlternateViews.Add(htmlView)
mail.Attachments.Add(New Attachment("c:\documents and settings\steely\my documents\expiredRecords.xls"))
'send the message
Dim smtp As New SmtpClient("place Ip here")
smtp.Send(mail)
End Sub
End Class
I have a windows service file, that runs fine through my test application (console program). I then placed my code into a windows service. After installing the service, I check the event logs and I keep seeing this error in the event log, which seems to be preventing further processing:
"Cannot create ActiveX component"
What am I doing wrong. I changed the settings on the application (through the services manager), so that the app uses my local logon information (instead of local)...
hmmm...any suggestions? I thought activex was just for web pages...and I am writing a service.
the service file pulls records from 2 tables and then exports those expired records to an excel document. the excel document is then emailed.
is the problem from my service or a setting?
thank you.
==Code from service=============
Imports System
Imports System.ComponentModel
Imports System.Data
Imports System.Data.SqlTypes
Imports System.Data.SqlClient
Imports System.Diagnostics
Imports System.Net
Imports System.Net.Mail
Imports System.ServiceProcess
Imports Pulls.showDropFiles
Imports Pulls.copyDropFiles
Imports Pulls.removeExpRecords
Imports Pulls.excelExport
Public Class BETCheckFiles
Public Sub New()
MyBase.new()
InitializeComponent()
If Not System.Diagnostics.EventLog.SourceExists("Expired Records") Then
System.Diagnostics.EventLog.CreateEventSource("Expired Records", "Expired Search Log")
EventLog1.Source = "Expired Records"
EventLog1.Log = "Expired Search Log"
End If
End Sub
Protected Overrides Sub OnStart(ByVal args() As String)
Try
If Pulls.getRecords.Rows.Count.ToString = 0 Then
EventLog.WriteEntry("As of " & Today & " There are no files for this week.")
Else
'**begin to count expired records
EventLog.WriteEntry(Today & " There are " & getRecords.Rows.Count.ToString & " expired records for this week.")
'**insertExpRecords() function will copy records to logging table and write process to log
insertExpRecords()
EventLog.WriteEntry(Today & " Success! Files Copied to logging table.")
'**export records to excel log file
exportrecs()
removeRecords()
EventLog.WriteEntry(Today & " Success! Log of records emailed and the expired records for this week have been removed from their respective tables.")
End If
Catch ex As Exception
EventLog.WriteEntry(ex.Message)
End Try
'send email
DropFilesEmails()
End Sub
Protected Overrides Sub OnStop()
' Add code here to perform any tear-down necessary to stop your service.
EventLog.WriteEntry(Today & "All files swept and the Service Stopped.")
End Sub
Public Sub DropFilesEmails()
'Create the mail message
Dim mail As New MailMessage()
'set the address
mail.From = New MailAddress("myname@test.net")
mail.To.Add("myname@test.net")
mail.IsBodyHtml = True
'create the content
mail.Subject = "Expired records Log Transaction for " & Today
'message body should be a formatted excel document (the html does not work here)
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(Today & " Attached you will find the log file for the Expiration Service. " & getRecords().Rows.Count.ToString & " records were logged for removal.")
mail.AlternateViews.Add(htmlView)
mail.Attachments.Add(New Attachment("c:\documents and settings\steely\my documents\expiredRecords.xls"))
'send the message
Dim smtp As New SmtpClient("place Ip here")
smtp.Send(mail)
End Sub
End Class