Index was outside the bounds of the Array. (Microsoft.SqlServer.smo)

前端 未结 12 1761
有刺的猬
有刺的猬 2020-12-02 22:08

I am using SQL Server 2008 R2. It is working fine. But recently, I have changed my hosting server and I came to know that they have installed SQL Server 2

12条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 22:11

    I had a similar experience with using SMO via C# with the stack trace:

    [1896] System.IndexOutOfRangeException: Index was outside the bounds of the array. 
    [1896]    at Microsoft.SqlServer.Management.Smo.BitStorage.SetBit(Int32 itemIndex, BitIndex bitIndex, Boolean value) 
    [1896]    at Microsoft.SqlServer.Management.Smo.SqlSmoObject.AddObjectPropsFromDataReader(IDataReader reader, Boolean skipIfDirty, Int32 startColIdx, Int32 endColIdx) 
    [1896]    at Microsoft.SqlServer.Management.Smo.SqlSmoObject.ImplInitialize(String[] fields, OrderBy[] orderby) 
    [1896]    at Microsoft.SqlServer.Management.Smo.SqlSmoObject.Initialize(Boolean allProperties) 
    [1896]    at Microsoft.SqlServer.Management.Smo.SqlSmoObject.OnPropertyMissing(String propname, Boolean useDefaultValue) 
    [1896]    at Microsoft.SqlServer.Management.Smo.PropertyCollection.RetrieveProperty(Int32 index, Boolean useDefaultOnMissingValue) 
    [1896]    at Microsoft.SqlServer.Management.Smo.PropertyCollection.GetValueWithNullReplacement(String propertyName, Boolean throwOnNullValue, Boolean useDefaultOnMissingValue) 
    [1896]    at Microsoft.SqlServer.Management.Smo.Information.get_MasterDBPath()
    

    It turned out my versions of the CLR/NCLI/SMO were 10.50.1600.1. Upgrading them to 10.53.6000.34 fixed it - thus allowing the 2008R2 SMO to do many things with 2012 and 2014 servers.

    Get them from the feature pack

    https://www.microsoft.com/en-gb/download/details.aspx?id=44272

提交回复
热议问题