views:

33

answers:

2

I'm posting the question that first appears here because it seems that it is dead on the Microsoft forums. Plus, Stack Overflow is better. :-P

I'm hosting a TCP endpoint in a worker role on Azure --

var _breadcrumbServiceHost = new ServiceHost(typeof(BreadcrumbService));
var binding = new NetTcpBinding(SecurityMode.None);
var externalEndPoint = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints["shuttles"];
_breadcrumbServiceHost.AddServiceEndpoint(typeof(IBreadcrumbService), binding, String.Format("net.tcp://{0}/BreadcrumbService", externalEndPoint.IPEndpoint));

And I get two thrown exceptions --

System.InvalidProgramException  -  Common Language Runtime detected an invalid program

and

Unhandled exception: System.Runtime.CallbackException: Async Callback threw an exception. ---> System.InvalidProgramException: Common Language Runtime detected an invalid program.
   at System.ServiceModel.Dispatcher.ErrorBehavior.HandleErrorCommon(Exception error, ErrorHandlerFaultInfo& faultInfo)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.HandleError(Exception error, ErrorHandlerFaultInfo& faultInfo)
   at System.ServiceModel.Dispatcher.ChannelDispatcher.HandleError(Exception error)
   at System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
   at System.ServiceModel.Dispatcher.ChannelHandler.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
   at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult result)
   at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
   at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)

It doesn't always happen -- sometimes Azure is perfectly happy.

Help!! Thanks.

A: 

According to this you could get this error from an invalid mapping.

In your case what is in parameter {0}, does this vary? Could the service be down?

Also, it happens when you register the service, not when it is actually called? If it is when it is called it could be a variation in the return values.

Shiraz Bhaiji
The content of parameter {0} is initialized in the line immediately beforehand. Also, this is a server, so the service being down is kind of the problem we're trying to fix...
David Pfeffer
Yes, but is it getting initialised to the same value each time? Something is varying, this is just to narrow it down.
Shiraz Bhaiji
Well it does vary based on whatever the load balancer tells it.
David Pfeffer
A: 

Solved it! It appears there's an issue with WCF hosted in a worker and IntelliTrace. Disabling IntelliTrace solved it.

David Pfeffer