c# - using SQL Server Management Objects (SMO) Developer Machine 32 bit - SQL Server 64 bit -
i develop windows forms application on 32 bit win7 machine , have sql server 2008 on same machine testing. database server of release inviroment has 64 bit. when install application on client (32 bit) in release inviroment connected 64 bit sql server following failure when code try use sql server management objects (smo):
code causes failure:
private static bool createdatabase(string dbname, string sqlpath, string connstr) { fileinfo file = new fileinfo(sqlpath + dbname + ".sql"); string strscript = file.opentext().readtoend(); bool result; string test = "create database [" + dbname + "]"; try { sqlconnection connection = new sqlconnection(connstr); using (connection) { using (sqlcommand sqlcmd = new sqlcommand(test, connection)) { connection.open(); sqlcmd.executenonquery(); connection.close(); result = true; } } if (result == true) { connstr = connstr + ";initial catalog=" + dbname; sqlconnection sqlconnection = new sqlconnection(connstr); serverconnection svrconnection = new serverconnection(sqlconnection); server server = new server(svrconnection); server.connectioncontext.executenonquery(strscript); // here app crashes } } catch (sqlexception ae) { result = false; system.windows.forms.messagebox.show(ae.message.tostring()); } return result; }
failure message:
anwendung: xingaadmin.exe frameworkversion: v4.0.30319 beschreibung: der prozess wurde aufgrund einer unbehandelten ausnahme beendet. ausnahmeinformationen: system.io.filenotfoundexception stapel: bei system.reflection.runtimeassembly._nload(system.reflection.assemblyname, system.string, system.security.policy.evidence, system.reflection.runtimeassembly, system.threading.stackcrawlmark byref, boolean, boolean, boolean) bei system.reflection.runtimeassembly.nload(system.reflection.assemblyname, system.string, system.security.policy.evidence, system.reflection.runtimeassembly, system.threading.stackcrawlmark byref, boolean, boolean, boolean) bei system.reflection.runtimeassembly.internalloadassemblyname(system.reflection.assemblyname, system.security.policy.evidence, system.threading.stackcrawlmark byref, boolean, boolean) bei system.reflection.runtimeassembly.internalload(system.string, system.security.policy.evidence, system.threading.stackcrawlmark byref, boolean) bei system.reflection.assembly.load(system.string) bei microsoft.sqlserver.management.common.serverconnection.getstatements(system.string, microsoft.sqlserver.management.common.executiontypes, int32 byref) bei microsoft.sqlserver.management.common.serverconnection.executenonquery(system.string, microsoft.sqlserver.management.common.executiontypes) bei xingacommonclasses.utilities.database.databasehelper.createdatabase(system.string, system.string, system.string) bei xingacommonclasses.utilities.database.databasehelper.checkdatabase(system.collections.generic.list`1, system.string) bei xingaadmin.program.main()
the database created fine, sql-script table creation not executed.
is possible have use 64 bit version of sql server management objects (smo)? if, how can version. cannot install 64 bit version on 32 bit machine.
this question contains same stack trace, stack dump contains information smo assembly failed load. use try-catch block dump stack trace in exception.
the sql server machine needs have 64bit smo library installed.
Comments
Post a Comment