我发布了第一次出现在这里的问题,因为它似乎在微软论坛上已经死了。另外,堆栈溢出更好。:-P
我在 Azure 上以辅助角色托管 TCP 端点——
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));
我得到了两个抛出的异常——
System.InvalidProgramException - Common Language Runtime detected an invalid program
和
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)
这并不总是发生——有时 Azure 非常高兴。
帮助!!谢谢。