My virtual machines are my playground and I do install/uninstall a lot of stuff there (of course related to SQL Server learning). When things break, I get to learn something new. In this blog we would talk about how to troubleshoot and fix Could not load file or assembly error. This particular error can come in many flavors. Here is another form of the same error.
Could not load file or assembly ‘Microsoft.SqlServer.BatchParser, Version=184.108.40.206, Culture=neutral, PublicKeyToken=89845dcd8080cc91’ or one of its dependencies. The system cannot find the file specified
You need to notice few things in the error message. I have shown the values as per the error message
- Assembly Name: Microsoft.SqlServer.BatchParser
- Version: 220.127.116.11
- Error Message: The system cannot find the file specified
If you check C:\WINDOWS\ASSEMBLY folder, you would see them like below.
Here is the version table:
|SQL Server Version||Assembly Version Number|
|SQL Server 2005||18.104.22.168|
|SQL Server 2008||10.0.0.0|
|SQL Server 2008 R2||10.0.0.0|
|SQL Server 2012||22.214.171.124|
|SQL Server 2014||126.96.36.199|
|SQL Server 2016||188.8.131.52|
|SQL Server 2017||184.108.40.206|
Now, read the error message again and it would start making sense. We can see that 220.127.116.11 is missing from assembly folder. All we need is to install the right version of SMO (Shared Management Objects) and SQLCLR from feature pack. You can refer below article to know more about feature pack. Since 18.104.22.168 is missing, we need SQL 2012 version of the feature pack.
In the article, I talked about Native Client but for current error, we need to download these files:
- ENU\x64\SQLSysClrTypes.msi for the X64 version
- ENU\x86\SQLSysClrTypes.msi for the X86 version
- ENU\x64\SharedManagementObjects.msi for the X64 version
- ENU\x86\SharedManagementObjects.msi for the X86 version
Hopefully, this blog would help some developer who has no idea about SQL Server versions jargon.
Reference: Pinal Dave (https://blog.sqlauthority.com)