无法加载文件或程序集“Microsoft.SqlServer.SqlClrProvider”? [英] Could not load file or assembly 'Microsoft.SqlServer.SqlClrProvider'?

查看:254
本文介绍了无法加载文件或程序集“Microsoft.SqlServer.SqlClrProvider”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
在我的项目中,我使用SMO和线程从数据库生成脚本并创建新数据库(在sql server 2008中),然后将表,...(数据除外)转移到新的一个。

我写下面的代码,所以这个错误出现在行中,创建一个服务器连接。



错误:



无法加载文件或程序集'Microsoft.SqlServer.SqlClrProvider,Version = 11.0.0.0,Culture = neutral,PublicKeyToken = 89845dcd8080cc91'或其依赖项之一。系统找不到指定的文件。



这是我的代码:



hi In my project i use SMO and threads for generating script from a data base and create a new database(in sql server 2008),then transfer tables,...(except data)in to the new one.
I write the code below,so this error appear in line which create a server connection.

the error :

Could not load file or assembly 'Microsoft.SqlServer.SqlClrProvider, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.

this is the mycode:

Thread th = new Thread(new ThreadStart(CreatDB));
th.Start();
public void CreatDB()
{
try
{


SqlConnection con2;
conString2 = " Data Source=MC040;Initial Catalog= CurrentDataBaseName;Integrated Security=SSPI";
con2 = new SqlConnection(conString2);

ServerConnection conn = new ServerConnection(con2);
Server srv = new Server(conn);

Transfer trsfrDB = new       Transfer(srv.Databases[CurrentDataBaseName]);
Microsoft.SqlServer.Management.Smo.Database newDatbase = new Microsoft.SqlServer.Management.Smo.Database(srv, "NewDBName");
newDatbase.Create();
ScriptingOptions options = new ScriptingOptions();
options.DriAll = true;
options.ClusteredIndexes = true;
options.Default = true;
options.Indexes = true;
trsfrDB.Options = options;
trsfrDB.CopyAllObjects = true;
trsfrDB.CopyAllViews = true;
trsfrDB.CopyAllUsers = true;
trsfrDB.CopyAllDefaults = true;
trsfrDB.CopyAllDatabaseTriggers = true;
trsfrDB.CopyAllUserDefinedTableTypes = true;
trsfrDB.CopyAllSchemas = true;
//Copy all user defined data types from source to destination
trsfrDB.CopyAllUserDefinedDataTypes = true;
//Copy all tables from source to destination
trsfrDB.CopyAllTables = true;
//Copy data of all source tables to destination tables
//It actually generates INSERT statement for destination
//trsfrDB.CopyData = true;
//Copy all stored procedure from source to destination
trsfrDB.CopyAllStoredProcedures = true;
//specify the destination server name
trsfrDB.DestinationServer = srv.Name;
trsfrDB.DestinationLoginSecure = false;
trsfrDB.DestinationLogin = "UserName";
trsfrDB.DestinationPassword = "Password";
trsfrDB.DestinationDatabase = "NewDBName";
trsfrDB.TransferData();

}
catch (System.Exception ex)
{
}
}





请告诉我如何解决这个问题。这对我来说非常重要。



please tell me how can i fix this problem.Its so important for me.

推荐答案

我自己解决。

添加到我的项目的所有程序集文件都应该在同一个版本中。我的代码得到错误,因为其中2个是版本11,但是另一个是在10.

与您的Windows服务器兼容的可用文件在这里:

C:\Program Files \ Microsoft Sql Server \ 100\SDK \Assemblies。
I solve it my self.
All the assemblies file that add to my project should have been in the same version.My code get error because 2 of them were in version 11,however the other were in 10.
The assebly files which are compatible with your sql server of you windows, are here:
C:\Program Files\Microsoft Sql Server\100\SDK\Assemblies.


请参考下面



https://social.msdn.microsoft.com/Forums/ SQLSERVER / EN-US / 1d2cb76b-642f-4067-9667-aacdbc142f74 / microsoftsqlserversqlclrpr oviderdll-ver-10xx?forum = sqlsmoanddmo [ ^ ]



https:/ /social.msdn.microsoft.com/Forums/sqlserver/en-US/d2b93633-42f0-4164-9646-c0ee64af402b/could-not-load-file-or-assembly-microsoftsqlserversqlclrprovider?forum=sqlsmoanddmo [< a href =https://social.msdn.microsoft.com/Forums/sqlserver/en-US/d2b93633-42f0-4164-9646-c0ee64af402b/could-not-load-file-or-assembly-microsoftsqlserversqlclrprovider?forum= sqlsmoanddmotarget =_ blanktitle =新窗口> ^ ]
Please refer below

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/1d2cb76b-642f-4067-9667-aacdbc142f74/microsoftsqlserversqlclrproviderdll-ver-10xx?forum=sqlsmoanddmo[^]

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/d2b93633-42f0-4164-9646-c0ee64af402b/could-not-load-file-or-assembly-microsoftsqlserversqlclrprovider?forum=sqlsmoanddmo[^]


这篇关于无法加载文件或程序集“Microsoft.SqlServer.SqlClrProvider”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆