Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am getting this error when using ESRI objects like Geometry, Envelope etc in a WCF service. I have a class that some properties (string, int, double) but when I add ESRI type as part of this class, it throws this error. Without ESRI objects, it wroks fine. I have tried to change the settings for timeout but that didn’t make any difference. I am hoping to get some feedback from other folks who have implementes ESRI objects from WCF service.

The underlying connection was closed: The connection was closed unexpectedly.

System.ServiceModel.CommunicationException was unhandled by user code
  Message=The underlying connection was closed: The connection was closed unexpectedly.
  Source=mscorlib
  StackTrace:
    Server stack trace: 
       at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)
       at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
       at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       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)
       at TEST.Services.Test.BoundaryService.IBoundaryService.GetBoundarySetSpatial(String boundarySetName, String boundaryName)
       at TEST.Services.Test.BoundaryService.BoundaryServiceClient.GetBoundarySetSpatial(String boundarySetName, String boundaryName) in C:\Projects\TESTGeoServices\TEST.Services.Test\Service References\BoundaryService\Reference.cs:line 57
       at TEST.Services.Test.BoundaryServiceTest.BoundaryService_GetBoundarySetSpatial_Test() in C:\Projects\TESTGeoServices\TEST.Services.Test\BoundaryServiceTest.cs:line 26
  InnerException: System.Net.WebException
       Message=The underlying connection was closed: The connection was closed unexpectedly.
       Source=System
       StackTrace:
            at System.Net.HttpWebRequest.GetResponse()
            at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
       InnerException:
share|improve this question
    
Are you running it on an STAThread? –  Kirk Kuykendall Apr 2 '13 at 23:03
    
I am not quite sure of STAThread, can't confirm if I am using STAThread or not. In terms of setup, have a wcf service and then BL class for logic and have Bo that has some properties. For this Bo, trying to add some properties like Geometry, Envelope etc. –  jay Apr 2 '13 at 23:19
    
Is Thread.CurrentThread.GetApartmentState() == ApartmentState.STA ? –  Kirk Kuykendall Apr 2 '13 at 23:27
    
More info here. –  Kirk Kuykendall Apr 2 '13 at 23:29
    
Could you provide more details? How does your WCF service contract look like? Are you referencing ESRI COM objects or interfaces in a WCF operation/data contract? If that's the case, you will need to define your own non-COM classes representing the data contract and convert between these and ESRI COM objects, so that at no point are ESRI COM objects exposed in the public contract. –  Petr Krebs Apr 3 '13 at 8:39

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.