Title: Unhandled SecurityException trying to Start example web service
Tags: vb.net;windows-services;securityexception
Question: I built the very simple Windows service and installer outlined in this article:
https://msdn.microsoft.com/en-us/library/aa984464%28v=vs.71%29.aspx
It seems to have built and installed fine, but when I try to start the service I get an unhandled security exception, which states "{"The source was not found, but some or all event logs could not be searched.  Inaccessible logs: Security."}"  on the following snippet in the Sub New() subroutine:
If Not EventLog.SourceExists("MySource") Then
EventLog.CreateEventSource("MySource", "MyNewLog")
End If
Per some articles I've found, I've added read permissions for NETWORK SERVICE account to the Security branch and parent EventLog branch in the registry, but I still get the same error.  Does anyone see the problem?
Thanks in advance for any help you may provide!


Here is another answer: Create a new key and string value like this;
Key= HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application\<Your app name&gt;\
String EventMessageFile value=C:\Windows\Microsoft.NET\Framework\v2.0.50727\EventLogMessages.dll

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2016:00:03/04/16', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<vb.net><windows-services><securityexception>', 'Title': 'Unhandled SecurityException trying to Start example web service', 'ViewCount': 58, 'id': 35807337, 'user_AboutMe': None, 'user_AccountId': 644640.0, 'user_DisplayName': 'Mike', 'user_Reputation': 417.0, 'user_Views': 49.0, 'user_id': 430984.0}}