【发布时间】:2018-01-14 22:13:56
【问题描述】:
我在尝试恢复 sqlserver 2012 中的数据库时遇到问题。
我的项目配置:
ASP.Net 核心 2.0, VS2017 Preview2, c#
我已经使用 nuget 包安装了 Microsoft.SqlServer.Scripting,然后我尝试使用以下代码恢复数据库
try
{
string DatabaseName = "TestDB";
String ConnectionString = "Data Source=(local);Initial Catalog= " + DatabaseName + ";Integrated Security=SSPI;";
SqlConnection sqlConnection = new SqlConnection(ConnectionString);
// Error on the line below
Microsoft.SqlServer.Management.Common.ServerConnection conn = new Microsoft.SqlServer.Management.Common.ServerConnection(sqlConnection);
Server srv = new Server(conn);
Console.WriteLine(srv.Information.Version);
}
catch (Exception ex)
{
string exepe = ex.Message.ToString();
}
错误是:
无法从 程序集'System.Data,版本=4.0.0.0,文化=中性, PublicKeyToken=b77a5c561934e089'。
我错过了什么吗?你能请任何人帮我解决这个问题吗?
【问题讨论】:
-
.NET Core 可能不存在(packagesearch 和 github corefx 上都不存在),您必须改为以 .NET Framework 为目标
-
您好 Tseng 感谢您的回复,是的,我尝试了 .Net Framework 也给出了同样的错误。我尝试在那里使用 Windows 应用程序。
标签: c# asp.net-core