Could not load file or assembly microsoft.sqlserve

2019-02-08 14:18发布

I run my Winforms app using SQLServer assemblies 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.

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.

The application has got referenced assemblies from: 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?

7条回答
神经病院院长
2楼-- · 2019-02-08 15:21

I had similar problem, my exception in Visual Studio was asking for: 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

All worked as expected.

Somewhere here there are generated some questions.

  1. Why there are two versions on DLLs?
  2. Why dll with version 13.0.1601 has version 13.100.0.0(Browsed by VS) and a other one with newer version 13.0.4424 has lower version 13.0.0.0(Browsed by 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”)

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.

Please use either the assemblies from the SDK folders or from SharedManagementObjects.msi to use as references for your applications.

-Charles Gagnon (chgagnon@microsoft.com)

查看更多
登录 后发表回答