简体   繁体   中英

Could not load file or assembly 'Microsoft.SqlServer.Smo, Version=10.0.0

  • OS : Microsoft Windows NT 5.2.3790 Service Pack 2 Version: 2.0.50727.42

Doing: creating Tables...

Rec: system.m.FileNotFoundexception: could not load file or assembly 'microsoft.sqlserver.smo, version=10.0.0.0, culture=neutral File name: 'microsoft.sqlserver.smo, version=10.0.0.0, culture=neutral, PublicKeyToken=89845dcd8080cc91' at claimsure.Forml.Runsqlscript(string connstring, streamReader sr) at myapp.Forml.bw_Dowork(object sender, DoworkeventArgs e) 'MN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value (NKLm\\software\\microsoft\\Fusion!enableLog] (DwoRD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value (NKLm\\software\\microsoft\\Fusion!enableLog).

I get the above error when running my application on a Windows 2003 server with SQL Server 2005.

I know there is a solution to download SQLServer2005_XMO from http://www.microsoft.com/en-us/download/details.aspx?id=24793

I have done this, but after the install a server reboot is required, which is not feasible for the time being.

I need to make use of the server object.

 using Microsoft.SqlServer.Management.Smo;
 using Microsoft.SqlServer.Management.Common;  

        using (SqlConnection connection = new SqlConnection(connString))
        {
            Server server = new Server(new ServerConnection(connection));
            server.ConnectionContext.StatementTimeout = 2400;
            server.ConnectionContext.ExecuteNonQuery(sqlString);

        }

Is is possible to load the dll in the same directory as my app and reference it from within the code?

Thanks.

edit: added full error

Resolved this by building an MSI installer and including all the DLL's required. Thanks for the pointers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM