my task: I want to display entries from the windows eventlog from my printjobs. I found various tutorials from msdn and different sites, but I cannot get access to my preferred protocol/service name.
Microsoft-Windows-PrintService
my Code ( c#):
string lists = EventLog.LogNameFromSourceName("Microsoft-Windows-PrintService/Operational", ".");
but this code is not working. Did somebody know a solution or a workaround for my problem. This is my first project in c#.
Thanks in Advance!
Your syntax for the call is correct. I think the source you are specifying in the call probably doesn't exist.
If you call EventLog.SourcesExists("Microsoft-Windows-PrintService/Operational") does it return false? If so, then the source string you are passing is incorrect and you need to find the correct source from Event Viewer.
Edit: In response to your later post, I don't think permissions have anything to do with it. I was able to access "Application and Services Logs" sources without doing anything special.
According to this previous post event log sources cannot be listed from the API but must be mined from the registry. However, I did find an application EventLogSourcesView that can generate a list of all event sources. It may be helpful in finding the source you are looking for.
Good luck!