.net 无法加载文件或程序集 microsoft.sqlserver.sqlclrprovider 13.100.0.0
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/38933680/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not load file or assembly microsoft.sqlserver.sqlclrprovider 13.100.0.0
提问by Oleg
I run my Winforms app using SQLServer assemblies Microsoft.SqlServer.ConnectionInfo (13.100.0.0) Microsoft.SqlServer.SMO(13.100.0.0)
我使用 SQLServer 程序集运行我的 Winforms 应用程序 Microsoft.SqlServer.ConnectionInfo (13.100.0.0) Microsoft.SqlServer.SMO(13.100.0.0)
On the same machine SSMS 2016(Aug) is installed. And here SQL 2014 Dev Edition is installed too.
在同一台机器上安装了 SSMS 2016(Aug)。这里也安装了 SQL 2014 Dev Edition。
WHen I run my app it gives me an error:
当我运行我的应用程序时,它给了我一个错误:
сonnection = new ServerConnection(instanceName);
------------
Could not load file or assembly ‘microsoft.sqlserver.sqlclrprovider version=13.100.0.0′
I have checked: GAC contains some this assemblies 11, 12, 13.0.0.0, but there is no 13.100.0.0.
我检查过:GAC 包含一些此程序集 11、12、13.0.0.0,但没有 13.100.0.0。
The application has got referenced assemblies from: C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Tasks
该应用程序已从以下位置获得引用的程序集:C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Tasks
Microsoft.SqlServer.ConnectionInfo (13.100.0.0)
Microsoft.SqlServer.SMO(13.100.0.0)
My OS is Windows 7 and I think all 13.100.0.0 were installed by SSMS installer. How to solve this problem? WHere I can find the assembly microsoft.sqlserver.sqlclrprovider 13.100.0.0?
我的操作系统是 Windows 7,我认为所有 13.100.0.0 都是由 SSMS 安装程序安装的。如何解决这个问题呢?在哪里可以找到程序集 microsoft.sqlserver.sqlclrprovider 13.100.0.0?
采纳答案by Soruk
I had the same issue. With the updated SSMS, the main SMO are now installed in "C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Tasks"with the version 13.100.0.0 in VS (the Microsoft.SqlServer.Smo.dll file has the 13.0.15700.28 version) but there is no Microsoft.SqlServer.SqlClrProvider.dll referenced in GAC. When I take the one provided with SSMS, I get an exception further into my code.
我遇到过同样的问题。使用更新的 SSMS,主 SMO 现在安装在"C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Tasks"VS 中的 13.100.0.0 版本中(Microsoft.SqlServer.Smo.dll 文件具有 13.0.15700.28 版本)但没有引用 Microsoft.SqlServer.SqlClrProvider.dll海关总署。当我使用 SSMS 提供的那个时,我的代码进一步出现异常。
The problem is that the installer of SSMS adds reference of these private SMO to list of references of Visual Studio. Charles Gagnon gave me a workaround (the use of the HintPath) that I implemented in my .csprojfiles.
问题是 SSMS 的安装程序将这些私有 SMO 的引用添加到 Visual Studio 的引用列表中。Charles Gagnon 给了我一个我在我的.csproj文件中实现的解决方法(使用 HintPath)。
回答by Charles Gagnon
Client applications should not be using the assemblies from the Program Files folders unless they are from the specific SDK folders (such as "C:\Program Files (x86)\Microsoft SQL Server\130\SDK")
客户端应用程序不应使用 Program Files 文件夹中的程序集,除非它们来自特定的 SDK 文件夹(例如“C:\Program Files (x86)\Microsoft SQL Server\130\SDK”)
The 13.100.* version of assemblies you are seeing are currently only for use by Microsoft tools and so are not placed with all needed dependencies being in the same place. The DTS folder especially has only a subset of SMO assemblies since that code does not need things such as SqlClrProvider.
您看到的 13.100.* 版本的程序集目前仅供 Microsoft 工具使用,因此未将所有需要的依赖项放在同一位置。DTS 文件夹尤其只有 SMO 程序集的一个子集,因为该代码不需要诸如 SqlClrProvider 之类的东西。
Please use either the assemblies from the SDK folders or from SharedManagementObjects.msi to use as references for your applications.
请使用 SDK 文件夹或 SharedManagementObjects.msi 中的程序集作为应用程序的参考。
-Charles Gagnon ([email protected])
-查尔斯·加格农 ([email protected])
回答by Jacob H
If anyone has the displeasure of running into this scenario, hopefully this helps. None of the suggested answers on this post (nor the ones linked to the MS Connect site, nor any of the other solutions for other versions of SQL, nor fixes for other unrelated DLL files, nor...) fixed my issue. Adding the reference to the DLL from the GAC resulted in another error Access Denied.
如果有人不高兴遇到这种情况,希望这会有所帮助。这篇文章中的建议答案(也不是链接到 MS Connect 站点的答案,也不是其他 SQL 版本的任何其他解决方案,也不是其他不相关的 DLL 文件的修复程序,也不是......)解决了我的问题。从 GAC 添加对 DLL 的引用导致另一个错误Access Denied。
Through a significant amount of troubleshooting the debug/bin folders of my application and comparing the versions of the SMO and SqlClrProvider DLL files, I noticed two things. A) The detailed error message/stack trace showed a reference to a separatedll, which is apparently a dependency for SMO, that DLL being Microsoft.SqlServer.ConnectionInfo.dll. B) I noticed that when the project compiled, the date/version of the ConnectionInfo.dll showed it was notbeing replaced when DLLs that the SMO and Common DLL references were modified. Since this appeared to be a dependency, this did not make sense.
通过对我的应用程序的 debug/bin 文件夹进行大量故障排除并比较 SMO 和 SqlClrProvider DLL 文件的版本,我注意到两件事。A) 详细的错误消息/堆栈跟踪显示了对单独dll的引用,这显然是 SMO 的依赖项,该 DLL 是 Microsoft.SqlServer.ConnectionInfo.dll。B)我注意到,当项目编译时,ConnectionInfo.dll 的日期/版本显示,当 SMO 和 Common DLL 引用的 DLL 被修改时,它没有被替换。由于这似乎是一个依赖项,因此这没有任何意义。
As a result, I added References to threedlls. Microsoft.SqlServer.Smo.dll, Microsoft.SqlServer.SqlClrProvider.dll and Microsoft.SqlServer.ConnectionInfo.dll. Note that I pulled these references from C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio. Which isn't the recommended location from MS (see above answers), but frankly at this point I don't care. It worked.
结果,我添加了对三个dll的引用。Microsoft.SqlServer.Smo.dll、Microsoft.SqlServer.SqlClrProvider.dll和 Microsoft.SqlServer.ConnectionInfo.dll。请注意,我从 C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio 中提取了这些引用。这不是 MS 推荐的位置(见上面的答案),但坦率地说,在这一点上我不在乎。有效。
Bottom Line: Try adding the connectioninfo.dll file to your references.
底线:尝试将 connectioninfo.dll 文件添加到您的引用中。
Not 100% sure if Copy Local = True is needed, but that property is set for all 3.
不是 100% 确定是否需要 Copy Local = True,但该属性已为所有 3 个设置。
Visual Studio 2013 and SQL Server 2014 if that is relevant.
Visual Studio 2013 和 SQL Server 2014(如果相关)。
edit: Ran into one more issue that is related to this mess. We also needed to include SqlServer.Management.sdk.sfc.dll and SqlServer.SqlEnum.dll too, as they relate to the Enums used by some of these calls. That brings the total references to 5 to fix this bug. Hope this helps someone!
编辑:又遇到了一个与这个烂摊子有关的问题。我们还需要包含 SqlServer.Management.sdk.sfc.dll 和 SqlServer.SqlEnum.dll,因为它们与其中一些调用使用的枚举相关。这使总引用数达到 5 以修复此错误。希望这可以帮助某人!
回答by Sdev
The Microsoft.SqlSever.SqlClrProvider can be installed by running the following MSIs:
可以通过运行以下 MSI 来安装 Microsoft.SqlSever.SqlClrProvider:
ENU\x64\SQLSysClrTypes.msi
ENU\x64\SQLSysClrTypes.msi
ENU\x64\SharedManagementObjects.msi
ENU\x64\SharedManagementObjects.msi
which are available form the following Microsoft download link: https://www.microsoft.com/en-us/download/details.aspx?id=52676
可从以下 Microsoft 下载链接获得:https: //www.microsoft.com/en-us/download/details.aspx?id=52676
The link provides a list of MSIs. You will have to navigate through the list to find the items above.
该链接提供了 MSI 列表。您必须浏览列表才能找到上面的项目。
Install the SQLSysClrTypes.msi first, followed by the SharedManagmentObjects.msi.
首先安装 SQLSysClrTypes.msi,然后安装 SharedManagmentObjects.msi。
The actually Microsoft.SqlSever.SqlClrProvider.dll will be installed into your GAC. The rest of the related assemblies will be installed in C:\Program Files\Microsoft SQL Server\130\
实际上 Microsoft.SqlSever.SqlClrProvider.dll 将安装到您的 GAC 中。其余相关程序集将安装在 C:\Program Files\Microsoft SQL Server\130\
回答by Paul.B
Turns out that in my case it was simply a question of adding all the DLLs with the same version number as references. This had to be done manually. They were all found in either C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Tasks\ (for Microsoft.SqlServer.Smo.dll) or C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\ in the case of Microsoft.SqlServer.SqlClrProvider.dll. If you look at the properties of all the related/required DLLs in these two folders, they all say version 13.0.15700. But once you browse to each one, and include it as a reference, the reference properties in VS2015 all say version 13.100.0.0??????? How about that! And it all works.
事实证明,在我的情况下,这只是添加具有相同版本号作为引用的所有 DLL 的问题。这必须手动完成。它们都位于 C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Tasks\(对于 Microsoft.SqlServer.Smo.dll)或 C:\Program Files (x86)\Microsoft SQL Server\130 \Tools\Binn\ManagementStudio\ 在 Microsoft.SqlServer.SqlClrProvider.dll 的情况下。如果您查看这两个文件夹中所有相关/必需 DLL 的属性,它们都会显示版本 13.0.15700。但是一旦你浏览到每一个,并将其作为参考,VS2015 中的参考属性都说版本 13.100.0.0??????? 那个怎么样!这一切都有效。
回答by Stavros Koureas
I had similar problem, my exception in Visual Studio was asking for: Microsoft.SqlServer.Diagnostics.STrace, Version=13.0.0.0
我有类似的问题,我在 Visual Studio 中的异常要求:Microsoft.SqlServer.Diagnostics.STrace, Version=13.0.0.0
In the Project References i was having a DLL with Version 13.0.1601... and the Version(Browsed by VS) was 13.100.0.0, so I replaced the DLL in the Project References with Version 13.0.4424... and the Version(Browsed by VS) was 13.0.0.0
在项目引用中,我有一个版本为 13.0.1601... 的 DLL,版本(由 VS 浏览)是 13.100.0.0,所以我用版本 13.0.4424... 和版本替换了项目引用中的 DLL (VS 浏览)是 13.0.0.0
All worked as expected.
一切都按预期工作。
Somewhere here there are generated some questions.
这里的某个地方产生了一些问题。
- Why there are two versionson DLLs?
- Why dll with version 13.0.1601has version 13.100.0.0(Browsed by VS) and a other one with newer version 13.0.4424has lower version 13.0.0.0(Browsed by VS)?
- 为什么DLL有两个版本?
- 为什么DLL与版本13.0.1601有版本13.100.0.0(通过VS浏览过的)和其他一个较新的版本13.0.4424已经较低版本13.0.0.0(由VS浏览过的)?
The clear answer:
明确的答案:
Client applications should not be using the assemblies from the Program Files folders unless they are from the specific SDK folders (such as “C:\Program Files (x86)\Microsoft SQL Server\130\SDK”)
客户端应用程序不应使用 Program Files 文件夹中的程序集,除非它们来自特定的 SDK 文件夹(例如“C:\Program Files (x86)\Microsoft SQL Server\130\SDK”)
The 13.100.* version of assemblies you are seeing are currently only for use by Microsoft tools and so are not placed with all needed dependencies being in the same place. The DTS folder especially has only a subset of SMO assemblies since that code does not need things such as SqlClrProvider.
您看到的 13.100.* 版本的程序集目前仅供 Microsoft 工具使用,因此未将所有需要的依赖项放在同一位置。DTS 文件夹尤其只有 SMO 程序集的一个子集,因为该代码不需要诸如 SqlClrProvider 之类的东西。
Please use either the assemblies from the SDK folders or from SharedManagementObjects.msi to use as references for your applications.
请使用 SDK 文件夹或 SharedManagementObjects.msi 中的程序集作为应用程序的参考。
-Charles Gagnon ([email protected])
-查尔斯·加格农 ([email protected])

