I am doing a C# project by VS2013 which is using smo object.
I installed
Install-Package Microsoft.SqlServer.Scripting
Install-Package Microsoft.SqlServer.SqlEnum.dll
by Nuget
and included
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo.Agent;
but getting the following error
Error 9 Assembly 'Microsoft.SqlServer.Smo, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' uses 'Microsoft.SqlServer.SqlEnum, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' which has a higher version than referenced assembly 'Microsoft.SqlServer.SqlEnum, Version=10.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'
any hand?
The problem is version mismatch between Smo and SqlEnum component, as the exception specifies.
The problem is that the package, you have used Install-Package Microsoft.SqlServer.SqlEnum.dll is an older package for SQL Server 2008.
There are folders containing the neccessary DLL files (Microsoft.SqlServer.SqlEnum.dll, Microsoft.SqlServer.ConnectionInfo.dll, Microsoft.SqlServer.Smo.dll) in your SQL Server installation folder:
C:\Program Files\Microsoft SQL Server\110\SDK\AssembliesC:\Program Files\Microsoft SQL Server\120\SDK\AssembliesYou can install all DLLs that you need also from Nuget in one package:
2012: https://www.nuget.org/packages/Unofficial.Microsoft.SQLServer.SMO/
2014: https://www.nuget.org/packages/Unofficial.Microsoft.SQLServer.SMO.2014/
Included DLLs: Microsoft.SqlServer.ConnectionInfo.dll, Microsoft.SqlServer.ConnectionInfoExtended.dll, Microsoft.SqlServer.Management.Sdk.Sfc.dll, Microsoft.SqlServer.Smo.dll, Microsoft.SqlServer.SmoExtended.dll, Microsoft.SqlServer.SqlClrProvider.dll, Microsoft.SqlServer.SqlEnum.dll
You should either use Microsoft.SqlServer.SqlEnum.dll & Microsoft.SqlServer.ConnectionInfo.dll file from that SDK\Assemblies folder that you have used when creating reference to Microsoft.SqlServer.Smo. Or you should install matching assemblies from NuGet. Version 11.0.0.0 of DLLs stands for SQL Server 2014.
See Files and Version Numbers and Create a Visual C# SMO Project in Visual Studio .NET.
If you install only one correct package from NuGet like https://www.nuget.org/packages/Unofficial.Microsoft.SQLServer.SMO.2014/, you should be OK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With