Custom Event Logging in a Windows Service - windows-services

In the project installer i am creating a custom event log. But when my service starts my all logs are going to the "Application" instead of my cuustom log. Below is the code which i have added to installer.
// Create Event Source and Event Log
EventLogInstaller logInstaller = new EventLogInstaller();
logInstaller.Source = "MyServices";
logInstaller.Log = "MyService Events";
Installers.Add(logInstaller);
Furthurmore the name of service is MyService.exe.
When I uninstall and re-install the service, i installation fail with the following install log;
Running a transacted installation.
Beginning the Install phase of the installation. See the contents of
the log file for the D:\MyService\MyService\bin\Release\MyService.exe
assembly's progress. The file is located at
D:\MyService\MyService\bin\Release\MyService.InstallLog.
An exception occurred during the Install phase.
System.ArgumentException: Source MyServices already exists on the
local computer.
The Rollback phase of the installation is beginning. See the contents
of the log file for the
D:\MyService\MyService\bin\Release\MyService.exe assembly's progress.
The file is located at
D:\MyService\MyService\bin\Release\MyService.InstallLog.
The Rollback phase completed successfully.
The transacted install has completed.
And this is how i write log entry;
EventLog.WriteEntry("MyServices", logMessage, logType);
Can someone please help me what wrong i am doing.

I had a similar problem and solved it by:
Stop current service.
Close task manager, service manage tool and windows event viewer.
Use intallutil.exe /u to uninstall current service.
delete event log registry key of current service.(This is important!)
(\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\yourCurrentLogName)
You can find your current log and you can confirm your deletion under windows event viewer.
Use installutil.exe to install service again.
Restart Windows.(This is important, too!)
I'm not sure whether it is necessary or not. But I kept getting errors even I logged out.
Everything got fine since I restart windows.
(Maybe AWS cached something?)

Need to create a EventSource in this way:
if (!EventLog.SourceExists(source))
{
var eventSourceData = new EventSourceCreationData(source, logName);
EventLog.CreateEventSource(eventSourceData);
}
source - "MyServices"
logName - some of your program name.
Insert the data need in this way:
log = new EventLog();
log.Source = "MyServices";
log.WriteEntry(message, entryType);

Related

Cannot compile the generated code. Please inspect the generated code via this exception's SourceCode property

I installed my private application which makes use of the Desktop Bridge and Dev Express XAF Winforms, from the Windows Store.
Then I uninstalled it using powershell
Remove-AppxPackage -Package *jobtalk*
Now when I try to reinstall from the store I get
Cannot compile the generated code. Please inspect the generated code via this exception's SourceCode property. The following errors occurred:
(0, 0): Error generating Win32 resource: Access is denied.
(0, 0): Unable to delete temporary file 'c:\Program Files\WindowsApps\jobtalk.jobtalk_1.0.1.0_neutral__8kpaqbvntb9aj\SBD.JobTalk.Workflow.Win\CSC88B14BFB7D314F00B0D1BB57EFD11.TMP' used for default Win32 resource -- The system cannot find the file specified.
[Update]
I think I need to install as administrator somehow.
The problem and solution are described at http://blog.delegate.at/
In order to contain app state, the bridge attempts to capture changes the app makes to AppData. All write to the user's AppData folder (e.g., C:\Users\user_name\AppData), including create, delete, and update, are copied on write to a private per-user, per-app location.

Waiting for an available agent / Waiting for an agent to be requested

(26.07.2016)I am using TFS2015 Update3 in a VM.
When I try to queue a build through the web interface or from Team Explorer, I get the following.
Then I restart all services related to TFS in services.msc and then after some time it starts working again.
So this happens too often.
I have a custom pool running:
Is there a way to debug this behaviour?
Examining the Log files
Link to Worker log file
Link to Agent log file
Exception occurs in this order here:
Checking if artifacts directory exists C:\workspaces\agent\_work\2\a
Deleting artifacts directory
System.ComponentModel.Win32Exception (0x80004005): The directory is not empty
at Microsoft.TeamFoundation.Common.FileSpec.DeleteDirectoryLongPath(String path, Boolean recursive, Boolean followJunctionPoints)
The weird thing is, queueing new build works most of the time, this happens only sporadically
It could be, that I have opened a file from that folder in notepad with many tabs open. Will observe if this issue persists and report.
If this is happening sporadically, it might a long path exists here in artifacts:
C:\workspaces\agent_work\2\a
Or, there was a cancelled build which left the artifact directory half cleaned which exposed a bug in cleaning.
The 2.x agent isn't subject to long paths (net core) but only works with 2017+:
https://github.com/Microsoft/vsts-agent
We can troubleshoot but it would be good to get to 2017+ (2018 QU3 is out) with a 2.x agent.
If that's not an option, message me and we can dig into what I think is a cancel / state bug.

Can't run HermesJMS from SOAP UI

I am trying to run HermesJMS from soapUI 5.2.1 on Windows7 x64
The preferences and path to hermes config are set correctly.
The problem is that I cannot write to C: drive. So I had to install SOAPUI and Hermes in alternative places. I have changed hermes_home, java_home and hermes_config to my actual paths. Paths do not contain whitespaces etc. When I run hermes.bat from command prompt, it starts correctly.
However, when I try SoapUI -> Project -> right click -> start HermesJMS - nothing happens. Things are as bad that I even couldn't find anything useful neither in soapui nor in hermes logs.
File structure is as follows:
hermes_home = ...\SoapUI-5.2.1\hermesJMS
hermes_config = ...\SoapUI-5.2.1\hermesJMS\cfg
Does anyone have an idea what could be going on? Or for a start where can i find stdout and stderr of a script which starts hermes from SoapUI?
Here are the steps to configure SoapUI with HermesJMS:
Preferences: In SoapUI tool, go to File -> Preferences -> Tools and set the path for HermesJMS, which is mentioned here in the documentation. Then, save the preferences.
Start HermesJMS: Now, select your soapui project. Right click -> Start HermesJMS. At this point, a dialog will be shown requesting user to choose for the hermes configuration directory where it looks for the file called hermes-config.xml. Default location it looks for is under {user.home}\.hermes.
You already mentioned hermesJMS is already configured to connect with TIBCO EMS, so you will be having that file on your system.
Configuring JMS: I believe this may not really applicable for you. But, in case if someone is needed, here are the detailed steps provided, citing the documentation.
-- Here for activemq from the official site.
-- Here for TIBCO EMS. And here, there. Also find some information relevant to EMS connection issues here.
Permissions Issue on C Drive:
There is no constraint from SmartBear that SoapUI needs to be installed in a specific drive on the computer. So, you are free to install the software on your machine where you have the rights to do so.
Does anyone have an idea what could be going on? Or for a start where can i find stdout and stderr of a script which starts hermes from SoapUI?
Best thing you could do is to go the logs to find what is going on. You can find lot of useful information from the logs when the situation requires. SoapUI logs can be found under {user.home} when you invoked it from windows -> start menu. If you start SoapUI from command line (go to SOAPUI_HOME\bin) using soapui.bat script, then you should be able so the log on the console itself also log files can be found in the same directory where you invoked.
This time the above instruction should resolve your issue.

Error while installing railsinstaller

I downloaded railsinstaller 2.1 on my PC. Every time I try to install it I get
Error 5: access denied.
Setup was unable to create directory "C:\Sites\todo"
Since it's giving me an access denied error, I should run the installer as administrator. Right? But I get the error either way.
That's very odd, right click the todo folder and select properties then click the security tab and verify that administrators have full control of that folder?
You could also try creating the folder first then running it, although it'll probably do the same when creating sub directories.

could not start the sphinx search service on local computer?

i am getting this
Windows could not start the SphinxSearch service on Local Computer.
Error 1067: The process terminated unexpectedly.
i got installation instruction from this .
http://blog.robbsnet.com/2011/07/how-to-install-and-implement-sphinx.html
build process is complete but when i start the sphinx search service i got errors .
Try running searchd manually from Command Prompt. Maybe it will give you a useful error message.
Try also looking in searchd.log
For anyone who is still having problems with the Windows service:
Make sure your configuration is correct for both database and paths and the needed folders & files are created.
Make sure that the service "command" matches the correct paths and files, to do so you have to:
Run administrative tools, click on local services, then find SphinxSearch. Click on its properties and read the line the service is trying to execute. If the configuration path doesn't match the service start command, it will fail to start.
FYI, this can also happen because your search data files are corrupt. Easy fix for that is to nuke the files and refill them.

Resources