Fixed WCF Azure Service Bus: Access is denied Exception

Fixed WCF Azure Service Bus: Access is denied Exception

Access is denied.

Really?! Could you be a little more explicit?

The Background

I ran into this error recently when trying to deploy an application at a client. We ended up spending way too much time figuring out the root cause of this exception due to the sheer lack of details. Worst of all, the exact same code was working just fine in our QA environment.

At the end of the day, it turned out that our production box did not have the custom Event Log Source that our logger was attempting to log to. Normally, Windows is kind enough to create the Event Log Source for you, but the application we were running did not have sufficient privileges (Access is denied). After we added the source manually, everything started working again.

The Stack Trace

Unhandled Exception

Unhandled Exception: ***** Exception***** Exception Message: Access is denied. Stack Trace:

Unhandled Exception: ***** Exception***** Exception Message: Access is denied. Stack Trace:

Server Stack Trace

Server stack trace: at System.ServiceModel.Channels.ServiceChannel.ThrowIfFaultUnderstood(Message reply, MessageFault fault, String action, MessageVersion version, FaultConverter faultConverter) at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)


Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

The Fix

To fix this error, create the event log source on your production machine. If your application lives in Windows Azure, you will need to perform a few extra steps.

C:\PS> New-Eventlog -source YourEventLog -logname Application

Please let me know if this saves you any time/hassle. I need something to make me feel better for all of the time I wasted trying to fix this issue.

Happy debugging.

Robert Greiner

Robert Greiner

Professional optimist. Passionate about cultivating high-performing teams @ scale by integrating the timeless wisdom of the past with the marvel of today's emergent technology in a practical way.

View Comments
Next Post

Could not establish trust relationship for the SSL/TLS secure channel

Previous Post

The Trust Equation

Subscribe for free

Subscribe to my newsletter and get the latest posts delivered right to your inbox for free. I don't spam and your email won't be shared with third-parties.

Thanks for subscribing!

Check your inbox to confirm your subscription.

Please enter a valid email address!