Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ActiveX component error in a windows service file??? 2

Status
Not open for further replies.

radiance

Programmer
Jan 4, 2003
164
US
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
 
Hello,

I encountered the same problem, Cannot create ActiveX Compontent, after converting my windows-app to a Windows service.
I'm still searching for a solution...


 
You'll need to start by doing some debugging, but from what you say it would appear that you're not getting past the OnStart method.

In your code what is Pulls? I'm asking as I see no code that creates an instance of this. Also, you have to remember that it's best to create everything in code when working with services.

Private MyPulls as Pulls = New Pulls.

If MyPulls.getRecords...

 
I just found a solution:
I run the service under a Network user acoount, not under local system.
Now it works.
 
Thank you so much!

My service works. You were right VitoMark, the problem was the account type that the service runs under. In addition, my other issue was a conflict with one of the functions of a class I referenced!

go figure...


Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top