error: 26 - Error Locating Server/Instance Specified

Apr 9, 2012 at 1:11 PM

 

I try execute code, and I get this error:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)

in

private static void Init() {

 Configuration config = new Configuration

();        

config.AddAssembly("Agathas.Storefront.Repository.NHibernate"

);
 
 
 

log4net.Config.

XmlConfigurator.Configure();

 config.Configure();

_SessionFactory = config.BuildSessionFactory();<======================================= error

}

Config:

 

 

 

any suggestions ?


full stack trace

   en System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
   en System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
   en System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity)
   en System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
   en System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
   en System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
   en System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
   en System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
   en System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
   en System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
   en System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
   en System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
   en System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
   en System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
   en System.Data.SqlClient.SqlConnection.Open()
   en NHibernate.Connection.DriverConnectionProvider.GetConnection()
   en NHibernate.Tool.hbm2ddl.SuppliedConnectionProviderConnectionHelper.Prepare()
   en NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper)
   en NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory)
   en NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
   en NHibernate.Cfg.Configuration.BuildSessionFactory()
   en Agathas.Storefront.Repository.NHibernate.SessionFactory.Init() en D:\Trabajo\ASP.NET\Patrones\ASPNetDesignPatterns-Release1\ASPNetDesignPatterns\Agathas.Storefront.Repository.NHibernate\SessionFactory.cs:línea 26
   en Agathas.Storefront.Repository.NHibernate.SessionFactory.GetSessionFactory() en D:\Trabajo\ASP.NET\Patrones\ASPNetDesignPatterns-Release1\ASPNetDesignPatterns\Agathas.Storefront.Repository.NHibernate\SessionFactory.cs:línea 32
   en Agathas.Storefront.Repository.NHibernate.SessionFactory.GetNewSession() en D:\Trabajo\ASP.NET\Patrones\ASPNetDesignPatterns-Release1\ASPNetDesignPatterns\Agathas.Storefront.Repository.NHibernate\SessionFactory.cs:línea 39
   en Agathas.Storefront.Repository.NHibernate.SessionFactory.GetCurrentSession() en D:\Trabajo\ASP.NET\Patrones\ASPNetDesignPatterns-Release1\ASPNetDesignPatterns\Agathas.Storefront.Repository.NHibernate\SessionFactory.cs:línea 50
   en Agathas.Storefront.Repository.NHibernate.Repositories.Repository`2.FindAll() en D:\Trabajo\ASP.NET\Patrones\ASPNetDesignPatterns-Release1\ASPNetDesignPatterns\Agathas.Storefront.Repository.NHibernate\Repositories\Repository.cs:línea 43
   en Agathas.Storefront.Services.Implementations.ProductCatalogueService.GetAllCategories() en D:\Trabajo\ASP.NET\Patrones\ASPNetDesignPatterns-Release1\ASPNetDesignPatterns\Agathas.Storefront.Services\Implementations\ProductCatalogueService.cs:línea 88
   en Agathas.Storefront.Controllers.Controllers.ProductCatalogueBaseController.GetCategories() en D:\Trabajo\ASP.NET\Patrones\ASPNetDesignPatterns-Release1\ASPNetDesignPatterns\Agathas.Storefront.Controllers\Controllers\ProductCatalogueBaseController.cs:línea 26
   en Agathas.Storefront.Controllers.Controllers.HomeController.Index() en D:\Trabajo\ASP.NET\Patrones\ASPNetDesignPatterns-Release1\ASPNetDesignPatterns\Agathas.Storefront.Controllers\Controllers\HomeController.cs:línea 26
   en lambda_method(Closure , ControllerBase , Object[] )
   en System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
   en System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
   en System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
   en System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a()
   en System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)

<

property name="connection.connection_string">Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Shop.mdf;Integrated Security=True;User Instance=True</property>

<add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />

 

 In project Agathas.Storefront.UI.Web.MVC, there are two files .mdf:

App_Data\ASPNETDB.MDF

App_Data\Shop.mdf