Bug 29221 - Could not load type 'Microsoft.SqlServer.Server.SqlContext' from assembly 'System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
Summary: Could not load type 'Microsoft.SqlServer.Server.SqlContext' from assembly 'Sy...
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data ()
Version: 3.12.0
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-04-18 01:18 UTC by Jared Hanks
Modified: 2018-03-13 11:07 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Jared Hanks 2015-04-18 01:18:19 UTC
Trying to use this:

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


//Set destination connection string
string connectionString = YourConnectionString;
SqlConnection Connection = new SqlConnection(connectionString);

//SMO Server object setup with SQLConnection.
Server server = new Server(new ServerConnection(Connection));  <---- PRODUCES ERROR

//Create a new SMO Database giving server object and database name
Database db = new Database(server, "TestSMODatabase");



Could not load type 'Microsoft.SqlServer.Server.SqlContext' from assembly 'System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

System.TypeLoadException: Could not load type 'Microsoft.SqlServer.Server.SqlContext' from assembly 'System.Data, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
  at Microsoft.SqlServer.Management.Common.ConnectionManager..ctor (System.Data.SqlClient.SqlConnection sqlConnectionObject) [0x00000] in <filename unknown>:0
  at Microsoft.SqlServer.Management.Common.ServerConnection..ctor (System.Data.SqlClient.SqlConnection sqlConnection) [0x00000] in <filename unknown>:0
  at MainClass.Main (System.String[] args) [0x003bc] in Program.cs:107
Comment 1 Miguel de Icaza [MSFT] 2015-12-24 15:34:39 UTC
Please attach a self-contained test case, and include operating system version, Mono version, package version for the code you are using.

It could be merely a package missing from your installation
Comment 2 Marek Safar 2018-03-13 11:07:42 UTC
We have not received the requested information. If you are still experiencing this issue please provide all the requested information and reopen the bug report.

Thank you!