Other aswers are helpful; I wanted to provide a details response for anyone who just discovered this issue. This was in reference to the issue above on Windows Server 2019.
1 - Try creating the source with code
The code should check for the source and create it if it does not already exist.
Sample code (powershell w/.NET):
$source = "MySource"
if (![System.Diagnostics.EventLog]::SourceExists($source)) {
[System.Diagnostics.EventLog]::CreateEventSource($source, 'Application')
}
[System.Diagnostics.EventLog]::WriteEntry($source, 'log message test', [System.Diagnostics.EventLogEntryType]::Information)
2 - Reboot PC/Server
Unlikely to help but an easy option.
3 - EventCreate CMD tool
Try using the cmd line tool 'eventcreate' to write the entry, it may give you more detail into the problem:
eventcreate /T Information /ID 20 /L Application /SO PEI /D “Raymondcc Event for My Program"
Error:
eventcreate : ERROR: Source parameter is used to identify custom applications/scripts only (not installed applications).
which means you can't add to sources that weren't created by eventcreate. This means that the the source was created by an application during install etc. and you should not attempt to make this work and instead pick a new source name (or none at all)
4 - Verify registry
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application<source name>
Where it says replace with the source you are trying to use. If you see EventMessageFile set to something like C:\Windows\Microsoft.NET\Framework64\v4.0.30319\EventLogMessages.dll, then it's OK. If you see an application path like c:\program files\my program.exe, then it will not work.
5 - Other options
there are ways to work around this but it is complicated. Basically it is far better to just use another source name if at all possible. If the key isn't necessary you could duplicate it (e.g. dupicate Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application<source name>), then delete it and see if there are any issues from using eventcreate from then on.