Microsoft Developer Network >
Página principal de foros
>
Visual C# General
>
console app won't work outside visual studio IDE
console app won't work outside visual studio IDE
- Hello,
I have a console app that uses a DB.xsd file to make calls to/from a database.
When I run the console app in debug/release within the visual studio IDE, it works without any problems.
But if I release/compile or run the debug copy outside of visual studiot it throws a DB error every time!
Here is the error:
Unhandled Exception: System.Data.SqlClient.SqlException: A network-related or in stance-specific error occurred while establishing a connection to SQL Server. Th e server was not found or was not accessible. Verify that the instance name is c orrect 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(TdsParserStateObj ect stateObj) at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternal ConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Bool ean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host , String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject , SqlConnectionString connectionOptions, Int64 timerStart) at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnecti on owningObject, SqlConnectionString connectionOptions, String newPassword, Bool ean redirectedUserInstance) at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdent ity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOp tions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConn ection owningConnection, DbConnectionPool pool, DbConnectionOptions options) at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owning Object) at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection o wningObject) at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection ownin gObject) at System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection ow ningConnection) at System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection ou terConnection, DbConnectionFactory connectionFactory) at System.Data.SqlClient.SqlConnection.Open() at
Does anyone know what I'm doing wrong with my compiling?
Thanks!!!
Respuestas
- Hi,
Are you moving your sdf file with your executable?
Also move your config file with too.- Marcado como respuestaRoahn LuoMSFT, Moderadormiércoles, 11 de noviembre de 2009 12:03
- Propuesto como respuestaTamer OzMVPdomingo, 08 de noviembre de 2009 5:11
Todas las respuestas
- Hi,
Are you moving your sdf file with your executable?
Also move your config file with too.- Marcado como respuestaRoahn LuoMSFT, Moderadormiércoles, 11 de noviembre de 2009 12:03
- Propuesto como respuestaTamer OzMVPdomingo, 08 de noviembre de 2009 5:11
Hello thanks for your response!
I did not have any sdf file in the output directory, so I just copied all files with the executable and now it is working. This will work fine for now, but just out of curiousity would it be possible for me to stuff everything into a single .exe?
Thanks!
Good day!hmm I did try embedded resource for all the files you mentioned (except of course the one that didn't exist)... but the app did not work as a stand alone exe, I must have done something wrong

