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

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


Attachments

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");
db.Create();

...

Errors:

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

System.TypeLoadException: Could not load type 'Microsoft.SqlServer.Server.SqlContext' from assembly 'System.Data, Version=2.0.0.0, 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

Note You need to log in before you can comment on or make changes to this bug.