我在使用 ExecuteNonQuery
时遇到问题。
这是我的代码:
var connString = @"Data Source=serwer01;Initial Catalog=PolsatCyfrowy;Integrated Security=True";
FileInfo file = new FileInfo("C:\\Users\\azbudniewek\\source\\repos\\UM2 V2\\UM2 V2\\scripts.sql");
string script = file.OpenText().ReadToEnd();
SqlConnection conn = new SqlConnection(connString);
Server server = new Server(new ServerConnection(conn));
server.ConnectionContext.ExecuteNonQuery(script);
这是错误:
System.IO.FileNotFoundException: The file or set 'Microsoft.SqlServer.BatchParser, version = 14.100.0.0, Culture = neutral, PublicKeyToken = 89845dcd8080cc91' or one of its company can not be loaded. The file can not be downloaded.
File name: 'Microsoft.SqlServer.BatchParser, version = 14.100.0.0, Culture = neutral, PublicKeyToken = 89845dcd8080cc91'in System.Reflection.RuntimeAssembly.GetType (RuntimeAssembly set, string name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack)
in System.Reflection.RuntimeAssembly.GetType (string name, Boolean throwOnError, Boolean ignoreCase)
我阅读了很多有问题的解决方案,但无能为力。
我应该再安装一个 SQL Server 吗?我已经在我的计算机上安装了 SQL Server 2014,带有程序集的文件夹如下所示:
我应该怎么做才能避免这个问题?我想我的程序集文件夹中应该有版本 14.100.0.0,但不知道如何更新它。也许有人知道?
最佳答案
我遇到了类似的问题。我有一个使用 Microsoft.SqlServer.SqlManagementObjects nuget 包的 SMO 应用程序。
该应用程序在我的电脑上运行完美,但在部署它并在我们的应用程序服务器上运行时,我遇到了错误。
无法加载文件或程序集“Microsoft.SqlServer.BatchParser.dll”或其依赖项之一。找不到指定的模块。
为了解决这个问题,我需要针对 x86 平台再次构建项目。
关于c# - 使用 ExecuteNonQuery c# 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51040998/