Troubleshooting Guide: SQL Server Error 6587 — Assembly Reference Redirected by External Policy
Why This Error Happens
This error occurs when SQL Server’s CLR integration attempts to load a .NET assembly, but an external binding policy (such as a publisher policy file or an entry in the machine/application configuration) redirects the assembly reference to a different version than the one originally registered. This typically happens due to a mismatched or orphaned policy assembly left behind after a .NET Framework update, a side-by-side (SxS) versioning conflict in the Global Assembly Cache (GAC), or an improperly configured app.config/machine.config binding redirect that does not align with the assembly version SQL Server expects. Corrupted or outdated policy files in the GAC on Windows Server 2025 are the most common trigger.
Step-by-Step Resolution Guide
Step 1: Identify the Conflicting Assembly and Policy
- Open SQL Server Error Log or Event Viewer (Windows Logs > Application) and locate Event ID 6587.
- Note the two assembly names/versions referenced in the message: the original reference and the redirected target.
- Run the following query to confirm the assembly registered inside SQL Server:
SELECT name, assembly_id, clr_name FROM sys.assemblies;
Step 2: Inspect and Clean the Global Assembly Cache (GAC)
- Open a command prompt as Administrator and navigate to:
C:\Windows\Microsoft.NET\assembly\GAC_MSIL
- Search for the policy assembly (named like
policy.x.x.AssemblyName) causing the redirect. - Use
gacutil -l <AssemblyName>to list all versions currently cached. - If an outdated or duplicate policy file is found, remove it using:
gacutil -u policy.x.x.AssemblyName
Step 3: Re-register the Correct Assembly Version in SQL Server
- Drop and re-add the assembly in SQL Server to force it to bind to the correct version:
ALTER ASSEMBLY [AssemblyName] FROM 'C:\Path\To\CorrectAssembly.dll'
WITH PERMISSION_SET = SAFE;
- Ensure the
.dllfile version matches exactly what SQL Server originally expected (check viasys.assembly_files).
Step 4: Correct Binding Redirects in Configuration Files
- Open
machine.configlocated at:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config
- Locate the
<dependentAssembly>and<bindingRedirect>entries under<runtime>that reference the affected assembly. - Update or remove the incorrect
newVersionattribute so it matches the version SQL Server is loading.
Step 5: Restart SQL Server and CLR Services
- Restart the SQL Server service via SQL Server Configuration Manager or:
net stop MSSQLSERVER && net start MSSQLSERVER
- This forces the CLR host inside SQL Server to reload all assemblies and policies cleanly.
Alternative or Verification Steps
- After restarting, re-run any stored procedures or CLR functions that previously failed, and confirm Event ID 6587 no longer appears in the Application log.
- If the issue persists, consider fully uninstalling and reinstalling the specific .NET Framework version via “Windows Features” (Control Panel > Programs > Turn Windows features on or off) to rebuild a clean GAC without conflicting policy files.