none
Simple Linq To SQL Classes and a simple WCF Service - An existing connection was forcibly closed by the remote host RRS feed

  • Question

  • Hi. I'm trying to do use these things, and get the following error:

    An existing connection was forcibly closed by the remote host

    It's an Windows 7 H&P, SQL 2008 R2 Advanced Express, VS 2010 SP1 and IIS 7.5, all local, up-to-date, and running as Administrator, environment. The connection with the SQL is alright, 'cause I'm using in other projects. Just a bit tricky with .dbml (Data Context, using Northwind database). All out-of-the box. I just removed the unused "using" directives. And they are all .NET 4.0 and Projects, not Web Sites.

    Here is the WCF Service(IService1.cs then Service1.svc):

    using System.Collections.Generic;
    using System.ServiceModel;

    namespace Contexto
    {
        public interface IService1
        {
            [OperationContract]
            List<Region> GetRegion();
        }
    }
    **************************
    using System.Collections.Generic;
    using System.Linq;

    namespace Contexto
    {
        public class Service1 : IService1
        {
            public List<Region> GetRegion()
            {
                var dc = new NorthwindDataContext();
                var lista = dc.Regions.ToList();
                return lista;
            }
        }
    }

    And to consume it, a Default.aspx with a Gridview. The service is called "h2websolutions", added by "Add Service Reference". They are all published at the local IIS 7.5, ok.

    using System;
    using System.Web.UI;
    using ContextoClient.h2websolutions;

    namespace ContextoClient
    {
        public partial class Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    LoadRegion();
                }
            }
            public void LoadRegion()
            {
                var wcf = new Service1Client();
                var dcregions = wcf.GetRegion();
                GridView1.DataSource = dcregions;
                GridView1.DataBind();
                wcf.Close();
            }
        }
    }

    And then, the error: "An existing connection was forcibly closed by the remote host".

    Any clues why?

    Thanks in adavance,

    Heitor.


    Helping improve public services through Information Technology

    Monday, July 9, 2012 2:33 PM

All replies