views:

191

answers:

2

I have a .NET web service that is trying to log to the Windows Event Log. However, when I try to send a SOAP request to a web method in this web service, I get back this error in the SOAP response:

System.InvalidOperationException: Cannot open log for source 'MySource'. You may not have write access. ---> System.ComponentModel.Win32Exception: Access is denied

I've tried Googling around for a solution. This one describes editing a registry key that does not exist for me in Windows 7 64-bit; same for this Microsoft page. This question is related but the only answer to it talks about a 'Source' key that does not seem to be anywhere in HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\eventlog\MySource. If I need to add a Source key, what does its value need to be? I am using impersonation in my web service's Web.config (<identity impersonate="true" />). This question is related as well but has no answers. This question is related but again its answer doesn't seem to pertain to the registry setup in Windows 7.

I have both <authentication mode="Windows" /> and <identity impersonate="true" /> set in my Web.config. However, even when I remove <authentication mode="Windows" />, I still get the "Cannot open log for source" error.

A: 
Kieren Johnstone
I don't think that's the problem. The sources already exist on my computer, so my code is not trying to create new sources, it's just trying to write to existing ones.
Sarah Vessels
Could you post your code, and a stack trace for the Exception please?
Kieren Johnstone
A: 

Hi, I am getting the same problem. It seems the problem is more of protected mode being on. If protected mode is turned on then event log is inaccessible, otherwise it can.

I am also not trying to create any event source. Just trying to write to an already created event source...

hoping for a relevant solution ...

Sheikh Usman