G
Guest
I am in the process of developing a Windows Service which will: (1) monitor multiple network shares; (2) marshal text file transfers into an SQL Server 2000 instance; and (3) provide messaging services via email and a customized event log viewer. An additional goal is to have the service provide a visual status indicator via an icon to be located in the Taskbar status area. The NotifyIcon component appears to be a logical candidate and worked perfectly from within a sample Windows Forms application. I was able to programmatically manipulate the NotifyIcon.Icon property, and thus change the icon in the Taskbar status area, without difficulty
However, my efforts at providing simliar functionality from within a sample Windows Service application have resulted in the following exception message
"Exception has been thrown by the target of an invocation.
The code from the Windows Service OnStart procedure is as follows
Protected Overrides Sub OnStart(ByVal args() As String
Tr
Dim rm As ResourceManager = ResourceManager.CreateFileBasedResourceManager("TrunkDataIcons", "c:\TrunkData", Nothing
Me.NotifyIcon1.Icon = CType(rm.GetObject("TrunkDataStarting"), Drawing.Icon
Me.NotifyIcon1.Visible = Tru
Catch ex As Exceptio
'service application; write the exception message to a text fil
Dim iFile As Integer = FreeFile(
FileOpen(iFile, "c:\exception.txt", OpenMode.Output
WriteLine(iFile, ex.Message.ToString
FileClose(iFile
End Tr
End Su
Since this is a Windows Service application, the 'c:\exception.txt' text file provides a handy location for exception messages.
The 'TrunkDataIcons.resources' file contains seven System.Drawing.Icon object references directed to seven distinct '.ico' files. For example, the 'TrunkDataStarting' object refers to the 'TrunkData_Starting.ico' file within the resources file. I validated the contents of the 'TrunkDataIcons' resource file through the use of a sample Windows Forms application. A command button was assigned to each of the seven System.Drawing.Icon objects contained within the resource file and a Click event was created for each to allow the NotifyIcon.Icon property, and hence the icon in the tray, to be changed accordingly. As was mentioned earlier, this worked perfectly and served to validate the use of the ResourceManager object and the associated resource file.
However, attempting to utilize the same code construct and assign the contents of the 'TrunkDataIcons' resource file to the NotifyIcon.Icon property via the ResourceManager within the Windows Service application results in the aforementioned exception. I am at my wits end. Any assistance would be greatly appreciated
Best Regards
Randall Powel
However, my efforts at providing simliar functionality from within a sample Windows Service application have resulted in the following exception message
"Exception has been thrown by the target of an invocation.
The code from the Windows Service OnStart procedure is as follows
Protected Overrides Sub OnStart(ByVal args() As String
Tr
Dim rm As ResourceManager = ResourceManager.CreateFileBasedResourceManager("TrunkDataIcons", "c:\TrunkData", Nothing
Me.NotifyIcon1.Icon = CType(rm.GetObject("TrunkDataStarting"), Drawing.Icon
Me.NotifyIcon1.Visible = Tru
Catch ex As Exceptio
'service application; write the exception message to a text fil
Dim iFile As Integer = FreeFile(
FileOpen(iFile, "c:\exception.txt", OpenMode.Output
WriteLine(iFile, ex.Message.ToString
FileClose(iFile
End Tr
End Su
Since this is a Windows Service application, the 'c:\exception.txt' text file provides a handy location for exception messages.
The 'TrunkDataIcons.resources' file contains seven System.Drawing.Icon object references directed to seven distinct '.ico' files. For example, the 'TrunkDataStarting' object refers to the 'TrunkData_Starting.ico' file within the resources file. I validated the contents of the 'TrunkDataIcons' resource file through the use of a sample Windows Forms application. A command button was assigned to each of the seven System.Drawing.Icon objects contained within the resource file and a Click event was created for each to allow the NotifyIcon.Icon property, and hence the icon in the tray, to be changed accordingly. As was mentioned earlier, this worked perfectly and served to validate the use of the ResourceManager object and the associated resource file.
However, attempting to utilize the same code construct and assign the contents of the 'TrunkDataIcons' resource file to the NotifyIcon.Icon property via the ResourceManager within the Windows Service application results in the aforementioned exception. I am at my wits end. Any assistance would be greatly appreciated
Best Regards
Randall Powel