FIX: Access violation when you maintain RBS with the .NET Framework 4.0 in related configuration file in SQL Server


Assume that you are using a custom Remote BLOB Storage (RBS) provider together with Runtime .NET Framework 4.0 to store blobs remotely for Microsoft SharePoint 2013. When you try to run the garbage cleanup that internally calls Microsoft.Data.SqlRemoteBlobs.Maintainer.exe, you receive the following error message during garbage collection:
Starting Maintainer tasks.
Starting Garbage Collection.
Starting Reference Scan.
<Time>:ERR:0:::AssemblyLoad:::An error occurred while reading extension file xxxx.RemoteBlobStoreProvider.dll.
<Time>:ERR:0:::AssemblyLoad::: System.BadImageFormatException: This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. (Exception from HRESULT: 0x8013101B)
<Time>:ERR:0:::AssemblyLoad::: at System.Reflection.Assembly.nLoadFile(String path, Evidence evidence)
<Time>:ERR:0:::AssemblyLoad::: at System.Reflection.Assembly.LoadFile(String path)<Time>:ERR:0:::AssemblyLoad::: at Microsoft.Data.SqlRemoteBlobs.ProviderClass.Initialize()

The Maintainer tool is compiled by using the .NET Framework 2.0 runtime, and it cannot load assemblies that are based on the .NET Framework 4.0 for the enumeration of blobs and garbage collection. For any .NET Framework application, you can use the application's configuration file, and add the supportedRuntime tag to use the later version of the .NET Framework. The configuration file of the Maintainer component is Microsoft.Data.SqlRemoteBlobs.MaintainerConfig.xml, as in the following example:
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
If you try to run the garbage cleanup, Microsoft.Data.SqlRemoteBlobs.Maintainer.exe encounters an access violation exception, as follows:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args)
at Microsoft.Data.SqlRemoteBlobs.InformationUtilities.InformationDetails()
at Microsoft.Data.BlobStores.LogProvider.CreateHeaderInformation()
at Microsoft.Data.BlobStores.LogProvider.Initialize(LogLevel logLevel)
at Microsoft.Data.BlobStores.DebugPrint.InitializeProviders()
at Microsoft.Data.BlobStores.DebugPrint.Initialize(Boolean initializeProviders)
at Microsoft.Data.BlobStores.DebugPrint.WriteLine(OperationType operation, LogLevel level, Int32 blobStoreId, Exception exception, String message, Object[] arg)
at Microsoft.Data.SqlRemoteBlobs.Maintainer.Maintainer.MainInternal() at Microsoft.Data.SqlRemoteBlobs.Maintainer.Maintainer.Main(String[] args)


The first exception occurs because the Maintainer tool is compiled by using the .NET Framework 2.0. The tool cannot load assemblies that are based on the .NET Framework 4.0. The access violation exception occurs when you try to initialize the logging providers for Microsoft.Data.SqlRemoteBlobs.Maintainer.exe.


The fix for this problem is available in the latest feature pack download for RBS.msi. If you have use the workaround that is suggested, you can remove or enable the logging-related tags and keeps the supportRuntime tag.

Note You can reinstall RBS by using the new RBS.msi to apply the fix without applying the update.


To work around this problem, add the following additional configuration to the configuration file together with the supportedRuntime tag. These tags disable the logging capability for the Maintainer tool because the exception is being thrown during the initializing of the logging providers.
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>

<add key="ConsoleLog" value="0" />
<add key="FileLog" value="0" />
<add key="CircularLog" value="0" />
<add key="EventViewerLog" value="0" />
<add key="DatabaseTableLog" value="0" />


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

文章識別碼:2960310 - 最後檢閱時間:2016年11月10日 - 修訂: 1