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:
- SQL Server 2012
C:\Program Files\Microsoft SQL Server\110\SDK\Assemblies
- SQL Server 2014,2016
C:\Program Files\Microsoft SQL Server\120\SDK\Assemblies
You 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.