Assume that you are using a custom RBS provider with Runtime .NET Framework 4.0 to store blobs remotely for SharePoint 2013. When you try to run the garbage cleanup which internally calls Microsoft.Data.SqlRemoteBlobs.Maintainer.exe, you receive the following exception 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 utility is compiled with Runtime .NET Framework 2.0 and cannot load assemblies based out of the .NET Framework 4.0 for enumeration of blobs and garbage collection. For any .NET Framework application, you can use its configuration file and add supportedRuntime tag to use the later version of the .NET Framework. The configuration file of Maintainer component is Microsoft.Data.SqlRemoteBlobs.MaintainerConfig.xml, here is an example:
Now if you try to run the garbage cleanup, Microsoft.Data.SqlRemoteBlobs.Maintainer.exe encounters an access violation exception, the exception stack is following:
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 utility is compiled with the .NET Framework 2.0 and cannot load assemblies based out of 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 issue was first fixed in the following cumulative update of SQL Server. After you apply the fix, the access violation exception issue should be resolved. If you have used the workaround suggested, you can go-ahead and remove/enable the Logging related tags and keeps the supportRuntime tag.
Note You could reinstall RBS by using the new RBS.msi to apply the fix without applying the update.
Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server:
To work around this situation you can add the following additional configuration to the configuration file together with the supportedRuntime tag. These tags disable logging capability for the Maintainer application as the exception is being thrown while initializing the logging providers.