>>>I am debugging a Visual Basic application to fit our own needs. The source code was given to me from the other team. As we need to have this application to run as a service, they preferred to send the code to us so we can troubleshoot what is going on. The code is only 50 lines of code.
>>>
>>>I found that the following line:
>>>
>>>App.LogEvent APPLICATION_STARTED, vbLogEventTypeInformation
>>>
>>>only logs an entry in the Event Viewer if the application is run as a service or from an EXE. If we run the application from Visual Basic, it does not log in the Event Viewer. Why?
>>
>>I have already seen this behavior (that says that log are only kept when running outside VB IDE) in a Microsoft book.
>>
>>I have also test it and it confirms what the book says.
>>
>>The book didn't says why.
>
>So, those applications that log something should avoid using the Event Viewer. It would be better to log in a SQL Server table for example.
Maybe you can use the Immediate Window while in Debugging.
Try to send to Debug.Print in addition to send to the Event Log. Those lines will not cause problems at execution and you be able to see data both at design time and at run time.
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com