Click here to Skip to main content
15,902,777 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I got this error Could not load file or assembly 'Microsoft.SqlServer.smo. version 12.0.0.0' while connecting my application to sql server.

My Code:

C#
string sqlConnectionString = cn.ConnectionString.ToString();
           SqlConnection conn = new SqlConnection(sqlConnectionString);
           StringBuilder sb = new StringBuilder();
           string script = string.Empty;
           Microsoft.SqlServer.Management.Smo.Server server = new Server(new ServerConnection(conn));
           try
           {
               MessageBox.Show(server.Information.Version.ToString());
           }
           catch (Exception EX) { }


If you solve this error it would be appreciated.



What I have tried:

I have written code like this

string sqlConnectionString = cn.ConnectionString.ToString();
SqlConnection conn = new SqlConnection(sqlConnectionString);
StringBuilder sb = new StringBuilder();
string script = string.Empty;
Microsoft.SqlServer.Management.Smo.Server server = new Server(new ServerConnection(conn));
try
{
MessageBox.Show(server.Information.Version.ToString());
}
catch (Exception EX) { }
Posted
Updated 17-Aug-16 21:10pm
Comments
Mehdi Gholam 17-Aug-16 1:55am    
Make sure the dll exists on the system you are testing on.
TarunKumarSusarapu 17-Aug-16 1:57am    
Actually this happens in the client system. Can we copy our dlls in Sdk folder to client system? should it work properly?

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900