N-Tier application. Underlying connection was closed

N-Tier application. Underlying connection was closed

Old forum URL: forums.lhotka.net/forums/t/10377.aspx


JacoM posted on Tuesday, May 17, 2011

Hi,

 

I'm new to the CSLA framework and I'm trying to write an N-Tier application so I can demo the framework to my company.

I'm really struggling to get the data access working. I keep getting the "The underlying connection was closed: The connection was closed unexpectedly." error every time I try to access a dataportal.fetch command.

I'm using a windows forms UI and WcfHost.

Here is some of the code in the app.config files and the web.config file. I'm really not even sure where to find the problem, so if more code is required just let me know.

WindowsFormsUI app.config

<code>

<appSettings>
    <add key="CslaAuthentication" value="Windows"/>
    <add key="CslaDataPortalProxy" value="Csla.DataPortalClient.WcfProxy, Csla"/>
    <add key ="CslaDataPortalUrl" value ="http://localhost:41337/WcfPortal.svc"/>
  </appSettings>
  <connectionStrings>
    <add name="RIMS_PC" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=&quot;C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\RIMS_PC.mdf&quot;;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient"/>
  </connectionStrings>

</code>

DAL library app.coinfig

<code>

<connectionStrings>
    <add name="CSLAtester.DAL.Properties.Settings.RIMS_PCConnectionString"
      connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=&quot;C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\RIMS_PC.mdf&quot;;Integrated Security=True;Connect Timeout=30;User Instance=True"
      providerName="System.Data.SqlClient" />
  </connectionStrings>

</code>

WcfHost web.config

<code>

<connectionStrings>
    <add name="RIMS_PC" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=&quot;C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\RIMS_PC.mdf&quot;;Integrated Security=True;Connect Timeout=30;User Instance=True" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.serviceModel>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
    <services>
      <service name="Csla.Server.Hosts.WcfPortal" behaviorConfiguration="returnFaults">
        <endpoint contract="Csla.Server.Hosts.IWcfPortal" binding="wsHttpBinding"/>
      </service>
      <service behaviorConfiguration="WcfPortalBehavior" name="Csla.Server.Hosts.Silverlight.WcfPortal">
        <endpoint address="" binding="basicHttpBinding" contract="Csla.Server.Hosts.Silverlight.IWcfPortal" bindingConfiguration="basicHttpBinding_IWcfPortal">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>

</code>

 

I'm using CSLA 4.1 and VS 2010 and MS SQL server 2008 R2

Any suggestions please

 

JacoM replied on Tuesday, May 17, 2011

I set up a tracelog,

and there is an exception happening at

Process action 'http://ws.lhotka.net/WcfDataPortal/IWcfPortal/Fetch'.

Is my SP maybe wrong? Originally I wrote everything myself, but after struggling with this I created a new project and created the business libraries and SPs from the database using CSLAGenFork.

Copyright (c) Marimer LLC