nhibernate截屏夏天的恼人错误

时间:2012-01-22 21:17:19

标签: c# .net visual-studio-2010

我试图追随nhibernate screnncast系列的夏天,但我被困在早期的一段时间。所以这就是问题所在:

当我尝试运行以下方法时:

public void GetMyTestDataXMLFile()
{
    SaveTestDatabase();
}

我收到以下错误:

    Test Report: file:///C:/Users/pina/AppData/Local/Temp/Gallio/TDNetRunner/Report/DataAccessLayerTest.dll.html
** NO TESTS WERE RUN (No tests found) **
Test 'M:DataAccessLayerTest.Tests.GetMyTestDataXMLFile' failed: SqlDbCommandBuilder.CreateSelectCommand(DataSet, string) failed for tableName = 'Customer'
    NDbUnit.Core.NDbUnitException: SqlDbCommandBuilder.CreateSelectCommand(DataSet, string) failed for tableName = 'Customer' ---> System.Data.SqlClient.SqlException: 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)
    at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
    at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
    at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity)
    at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject)
    at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, TimeoutTimer timeout)
    at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance)
    at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
    at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
    at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options)
    at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
    at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
    at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject)
    at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection)
    at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
    at System.Data.SqlClient.SqlConnection.Open()
    at NDbUnit.Core.SqlClient.SqlDbCommandBuilder.getSchemaTable(SqlCommand sqlSelectCommand)
    at NDbUnit.Core.SqlClient.SqlDbCommandBuilder.CreateSelectCommand(DataSet ds, String tableName)
       --- End of inner exception stack trace ---
    at NDbUnit.Core.SqlClient.SqlDbCommandBuilder.CreateSelectCommand(DataSet ds, String tableName)
    at NDbUnit.Core.DbCommandBuilder.BuildCommands(Stream xmlSchema)
    at NDbUnit.Core.NDbUnitTest.ReadXmlSchema(Stream xmlSchema)
    at NDbUnit.Core.NDbUnitTest.ReadXmlSchema(String xmlSchemaFile)
    at Microdesk.Utility.UnitTest.DatabaseUnitTestBase.SaveDatabase(String connectionString, String schemaFilePathName, String datasetFilePathName, DatabaseClientType clientType)
    at Microdesk.Utility.UnitTest.DatabaseUnitTestBase.SaveTestDatabase()
    TestClass1.cs(291,0): at DataAccessLayerTest.Tests.GetMyTestDataXMLFile()

唯一的区别是我使用的是本地数据库(.sdf文件)。我确定它必须与连接字符串相关,但我似乎无法解决这个问题。

这是我的app.config文件:

    <?xml version="1.0"?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="testDatabase"
             connectionString="Data Source=H:\Code\NHibernateSample\DataAccessLayer\FirstSample.sdf"
             providerName="Microsoft.SqlServerCe.Client.3.5"/>
    </connectionStrings>
</configuration>

我正在使用VS 2010。

有人可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

我已经设法搞清楚了。测试驱动框架似乎并不完全支持使用.sdf文件&amp; SQLServerCe。我已经安装了一个新的SQL Server本地实例并创建了一个新的数据库,所有内容都已修复。

稍后我将发布新的app.config文件。