none
VS 2013 -> VS 2015 Error: An existing connection was forcibly closed by the remote host RRS feed

  • Question

  • I installed Visual Studio 2015 and it seems to have broken something on my system. I have not opened my solutions in the new VS2015 but installation of it or one of its components are breaking things. All was working fine before but now I cannot get it to work. I also cannot find any related breaking changes or fixes. Any ideas?

    Error

    The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:10:00'.



    • Moved by Tina-Shi Friday, August 21, 2015 2:17 AM related to the WCF
    Tuesday, August 18, 2015 2:39 PM

Answers

  • Hi JayantKimothi,

    According to this case, I create a new solution in VS2015 and it worked fine.

    So I suggest you can create a new solution in vs2015 and copy those codes

    in this solution.

    Node: if  your solution running in vs 2013 with .NETFramework 4.5. If so, you

    need chose a correct version in VS 2015. Because in vs 2013 the .NETFramework

    latest version updated to 4.5.1.But in vs 2015 it updated to 4.6.

    I hope that will be helpful to you.

    Best Regards,

    Grady

    Friday, August 21, 2015 9:52 AM
    Moderator

All replies

  • Hi JayanKimothi,

    Thank you for posting in MSDN forum.

    Could you please tell me what type solution/project you open in VS2015 and then get the above error message?

    Since you created this solution in VS2013 and then migrated to this VS2015, so I suggest you'd better ensure this solution works fine in original VS2013.

    If your solution work fine in VS2013 and then just get this error after migrating to VS2015, to check if this issue is related to this VS2015 IDE, I suggest you could try to create a simple same type solution/project in VS2015 and then check if yuou get same error message.

    In addition, I did some research about this error message, I found that this error is occurs in WCF solution/project.

    So if your solution is WCF, I suggest you could share the mainly code about your solution so that we find the correct forum support this issue.

    Please try the above suggestions to troubleshooting this issue and then share me latest message about it.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, August 19, 2015 9:20 AM
  • Hi Tina-Shi,

    My solution was created in VS 2013 and this is a WCF solution, before installing VS 2015 it was working fine I was able to communicate with WCF service. After installation it stopped working in both VS2013 as well as in VS2015, I am even not able to browse wcf service.

    Error:

    ---------------------------
    ---------------------------
    The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.   at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelFactory.OnClose(TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannelFactory.TypedServiceChannelFactory`1.OnClose(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
       at System.ServiceModel.ChannelFactory.OnClose(TimeSpan timeout)
       at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout)
       at System.ServiceModel.ChannelFactory.System.IDisposable.Dispose()
       at TestClient.Form1.enrollBtn_Click(Object sender, EventArgs e) in c:\TestService\TestClient\Form1.cs:line 45
    ---------------------------
    OK   
    ---------------------------

    And the same code is working fine in different machine having only VS2013.

    TestService.sln

    Contract Project: TestServiceInterface.csproj

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.ServiceModel;
    using System.Text;
    
    namespace TestServiceInterface
    {
        [ServiceContract]
        public interface IStudentEnrollmentService
        {
            [OperationContract]
            void EnrollStudent(Student s);
    
            [OperationContract]
            Student[] GetEnrolledStudents();
        }
    }
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.Serialization;
    using System.Text;
    
    namespace TestServiceInterface
    {
        [DataContract]
        public class Student
        {
            private string name;
    
            [DataMember]
            public string StudentName
            {
                set { this.name = value; }
                get { return this.name; }
            }
        }
    }
    

    TestServiceDAL.csproj - mockDAL

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace TestServiceDAL
    {
    
        public class StudentDatabase
        {
            private static List<string> studentData = new List<string>();
    
            public void AddStudent(string studentName)
            {
                studentData.Add(studentName);
            }
    
            public List<string> GetStudentList()
            {
                return studentData;
            }
        }
    }
    

    TestService.csproj: Wcf Service:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using TestServiceDAL;
    using TestServiceInterface;
    
    namespace TestService
    {
        public class EnrollmentService : IStudentEnrollmentService
        {
            public void EnrollStudent(Student s)
            {
                StudentDatabase sd = new StudentDatabase();
                sd.AddStudent(s.StudentName);
            }
    
            public Student[] GetEnrolledStudents()
            {
                StudentDatabase sd = new StudentDatabase();
                List<string> studentList = sd.GetStudentList();
                Student[] studentArray = new Student[studentList.Count];
                for (int i = 0; i < studentList.Count; i++)
                {
                    Student s = new Student();
                    s.StudentName = studentList[i];
                    studentArray[i] = s;
                }
                return studentArray;
            }
        }
    }
    

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.ServiceModel;
    using System.ServiceModel.Description;
    using System.Text;
    using System.Threading.Tasks;
    using TestServiceInterface;
    
    namespace TestService
    {
        class Program
        {
            static ServiceHost host = null;
    
            static void StartService()
            {
                host = new ServiceHost(typeof(EnrollmentService));
               
                //host.AddServiceEndpoint(new ServiceEndpoint(
                //     ContractDescription.GetContract(typeof(IStudentEnrollmentService)),
                //     new WSHttpBinding(), 
                //     new EndpointAddress("http://localhost:8732/awesomeschoolservice"))); 
                 
                host.Open();
            }
    
            static void CloseService()
            {
                if (host.State != CommunicationState.Closed)
                {
                    host.Close();
                }
            }
    
            static void Main(string[] args)
            {
                StartService();
    
                Console.WriteLine("Student Enrollment Service is running....");
                Console.ReadKey();
    
                CloseService();
            }
        }
    }
    
    service - app.config
    <?xml version="1.0"?>
    <configuration>   
      <system.serviceModel>
        <services>
          <service name="TestService.EnrollmentService" behaviorConfiguration="DefaultBehavior">
            <host>
              <baseAddresses>
                <add baseAddress="http://localhost:8732/awesomeservice" />
              </baseAddresses>
            </host>
            <endpoint address="" binding="wsHttpBinding" contract="TestServiceInterface.IStudentEnrollmentService"/>
            <endpoint address="mex" binding="wsHttpBinding" contract="IMetadataExchange"/>
          </service>
        </services>
        <behaviors>
          <serviceBehaviors>
            <behavior name="DefaultBehavior">
              <serviceDebug includeExceptionDetailInFaults="true"/>
              <serviceMetadata httpGetEnabled="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
      </system.serviceModel>
      <startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
      </startup>
    </configuration>

    TestClient.csproj : Client Project

    having two TextBox and two Buttons.

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.ServiceModel;
    using System.Text;
    using System.Windows.Forms;
    using TestServiceInterface;
    
    namespace TestClient
    {
        public partial class Form1 : Form
        {
            private ChannelFactory<IStudentEnrollmentService> factory = null;
            public Form1()
            {
                InitializeComponent();
            }
    
            private void enrollBtn_Click(object sender, EventArgs e)
            {
                if (studentNameTxt.Text == "") return;
    
                //factory = new ChannelFactory<IStudentEnrollmentService>("MyStudentEnrollmentServiceEndpoint");
                //factory.Open();
                //IStudentEnrollmentService service = factory.CreateChannel();
                //Student s = new Student();
                //s.StudentName = studentNameTxt.Text;
                //service.EnrollStudent(s);
                //factory.Close();
    
                try
                {
                    using (ChannelFactory<IStudentEnrollmentService> schoolServiceProxy =
                    new ChannelFactory<IStudentEnrollmentService>("MyStudentEnrollmentServiceEndpoint"))
                    {
                        schoolServiceProxy.Open();
                        IStudentEnrollmentService schoolEnrollmentService = schoolServiceProxy.CreateChannel();
                        Student s = new Student();
                        s.StudentName = studentNameTxt.Text;
                        schoolEnrollmentService.EnrollStudent(s);
                        schoolServiceProxy.Close();
                    }
                }
                catch (Exception ex)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append(ex.Message);
                    sb.AppendLine(ex.StackTrace);
                    MessageBox.Show(sb.ToString());
                }
    
    
                studentNameTxt.Text = "";
            }
    
            private void getEnrollBtn_Click(object sender, EventArgs e)
            {
                enrolledTxt.Text = "";
                try
                {
                    using (ChannelFactory<IStudentEnrollmentService> schoolServiceProxy =
                    new ChannelFactory<IStudentEnrollmentService>("MyStudentEnrollmentServiceEndpoint"))
                    {
                        schoolServiceProxy.Open();
                        IStudentEnrollmentService schoolEnrollmentService = schoolServiceProxy.CreateChannel();
                        Student[] enrolledStudents = schoolEnrollmentService.GetEnrolledStudents();
                        foreach (Student s in enrolledStudents)
                        {
                            enrolledTxt.AppendText(s.StudentName + "\n");
                        }
                        schoolServiceProxy.Close();
                    }
                }
                catch (Exception ex)
                {
                    StringBuilder sb = new StringBuilder();
                    sb.Append(ex.Message);
                    sb.AppendLine(ex.StackTrace);
                    MessageBox.Show(sb.ToString());
                }
            }
        }
    }
    

    <?xml version="1.0"?>
    <configuration>
      <system.serviceModel>
        <bindings>
          <wsHttpBinding>
            <binding name="HttpBinding_IEnrollmentService"/>
          </wsHttpBinding>
        </bindings>
        <client>
          <endpoint address="http://localhost:8732/awesomeservice" binding="wsHttpBinding" bindingConfiguration="HttpBinding_IEnrollmentService" contract="TestServiceInterface.IStudentEnrollmentService" name="MyStudentEnrollmentServiceEndpoint">
          </endpoint>
        </client>
      </system.serviceModel>
    </configuration>
    <!--<startup>
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
      </startup>-->
    Thursday, August 20, 2015 6:58 PM
  • Hi JayanKimothi,

    Since this issue is more related to the WCF, so we move this case to this WCF forum, you will get better support.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, August 21, 2015 2:16 AM
  • Hi JayantKimothi,

    According to this case, I create a new solution in VS2015 and it worked fine.

    So I suggest you can create a new solution in vs2015 and copy those codes

    in this solution.

    Node: if  your solution running in vs 2013 with .NETFramework 4.5. If so, you

    need chose a correct version in VS 2015. Because in vs 2013 the .NETFramework

    latest version updated to 4.5.1.But in vs 2015 it updated to 4.6.

    I hope that will be helpful to you.

    Best Regards,

    Grady

    Friday, August 21, 2015 9:52 AM
    Moderator
  • You have to get the inner exception message in the ex.message that should give the reason why the connection was closed.
    Saturday, August 22, 2015 1:04 PM