System.IO.FileNotFoundException: Unable to load file or assembly Microsoft.SqlServer.Management.SqlParser

182 Views Asked by At

For some years we have been maintaining a customer's system that suddenly stopped working.

The system is developed in C#, framework 4, uses NHibernate as ORM, the design pattern is MVP, connects to a SQL Server database and is distributed using ClickOnce.

In the development environment (in different configurations: Debug, Release, QA, Production) the system runs normally. The build is generated without problems, as well as the release and installation of new versions.

The problem is that at startup it returns an exception:

`System.IO.FileNotFoundException: Unable to load file or assembly 'Microsoft.SqlServer.Management.SqlParser, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd808080cc91'.`

In fact on the machines where it is developed, where it can be run normally from visual studio, it generates the same exception if installed.

We have made no changes to the database connection features and no new features have been added in this regard. There are no explicit references to this component in the system. It does happen that in the project file (.csproj) there is a PublishFile section that includes it:

`<PublishFile Include="Microsoft.SqlServer.Management.SqlParser">
    <Visible>False</Visible>.
    <Group>
    </Group>
    <TargetPath>
    </TargetPath>
    <PublishState>Include</PublishState>
    <IncludeHash>True</IncludeHash>
    <FileType>Assembly</FileType>
</PublishFile>`

In the Application Files view -Visual Studio project properties- it is marked with a warning (we hadn't noticed this because to see it you need to check the "Show all files" checkbox) . Application Files view

In my web tour I did not find anything about this error and the little I found is referred to SQL Server 2017. But the client uses SQL Server 2014.

TSqlLanguageService.msi (CTP 2.1)

Issue and customer impact: After installing on a computer that has a 2016 version of TSqlLanguageService.msi installed (either through SQL Setup or as a standalone redistributable) the v13. (SQL 2016) versions of Microsoft.SqlServer.Management.SqlParser.dll and Microsoft.SqlServer.Management.SystemMetadataProvider.dll are removed. Any application that has a dependency on the 2016 versions of those assemblies stops working and generate an error similar to: error : Could not load file or assembly 'Microsoft.SqlServer.Management.SqlParser, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the specified file.

In addition, attempts to reinstall a 2016 version of TSqlLanguageService.msi fail with the message: Installation of Microsoft SQL Server 2016 T-SQL Language Service failed because a higher version already exists on the machine.

Workaround To work around this issue and fix an application that depends on the v13 version of the assemblies follow these steps:

Go to Add/Remove Programs Find Microsoft SQL Server 2019 T-SQL Language Service CTP2.1, right-click it, and select Uninstall. After the component is removed, repair the application that is broken or reinstall the appropriate version of TSqlLanguageService.MSI. This workaround removes the v14 version of those assemblies, so any applications that depend on the v14 versions will no longer function. If those assemblies are needed, then a separate installation without any side-by-side 2016 installs is required.

Or, a reply on the Microsoft forum where the proposed solution is to install Microsoft® SQL Server® 2012 Transact-SQL Language Service. (I have already installed this component without success, the dll still does not appear.)

We, as developers, have no control over what the customer do with their servers, but on the other hand the problem occurs when running the program on the client machine, so I assume the problem is here.

On the other hand I am not used to make abrupt changes in something that was working normally until very recently and stops working for no apparent reason.

Any help about this problem will be welcome, thank you very much for reading.

0

There are 0 best solutions below