How to fix Error 6501 on Windows Server 2025 / Windows 11

Troubleshooting Guide: SQL Server Error 6501 – CREATE/ALTER ASSEMBLY Failed

Why This Error Happens

This error occurs when SQL Server 2025 cannot physically access the DLL or assembly file specified in the CREATE ASSEMBLY or ALTER ASSEMBLY statement, typically because the SQL Server service account lacks NTFS read permissions on the file or folder. It can also result from an incorrect file path, a file that has been moved or deleted, or the file being locked by another process, antivirus software, or Windows Defender’s enhanced scanning features on Windows Server 2025. Additionally, if the assembly resides on a network share (UNC path), authentication or firewall restrictions between the SQL Server host and the file server can block access.

Step-by-Step Resolution Guide

Step 1: Verify the File Path and Existence

  • Confirm the exact path used in your CREATE ASSEMBLY ... FROM 'path' statement matches the actual file location.
  • Open File Explorer or run dir "C:\SQLAssemblies\YourAssembly.dll" in Command Prompt to confirm the file exists.
  • Check for typos, incorrect drive letters, or case-sensitivity issues if using a mapped network path.

Step 2: Grant NTFS Permissions to the SQL Server Service Account

  • Identify the service account running SQL Server via SQL Server Configuration Manager > SQL Server Services.
  • Right-click the folder containing the DLL (e.g., C:\SQLAssemblies\) > Properties > Security tab.
  • Add the service account (e.g., NT Service\MSSQLSERVER or a custom domain account) and grant Read & Execute permissions.
  • Click Apply, then restart the SQL Server service for permissions to take effect.

Step 3: Check for File Locks or Antivirus Interference

  • Use Resource Monitor (resmon.exe) on Windows Server 2025 to check if another process has locked the DLL file.
  • Temporarily disable Windows Defender real-time protection or add an exclusion for the assembly folder via Windows Security > Virus & threat protection > Exclusions.
  • Re-attempt the CREATE ASSEMBLY command after confirming no lock exists.

Step 4: Validate Network Share Access (If Applicable)

  • If the DLL is hosted on a UNC path (e.g., \\FileServer\Assemblies\MyAssembly.dll), ensure the SQL Server service account has both share-level and NTFS-level read permissions.
  • Test connectivity using Test-NetConnection -ComputerName FileServer -Port 445 in PowerShell to rule out firewall blocking SMB traffic.
  • Consider copying the file locally to the SQL Server host as a workaround if network latency or authentication (Kerberos double-hop) is suspected.

Step 5: Rebuild or Replace a Corrupted Assembly File

  • If permissions and paths are correct but the error persists, the DLL file itself may be corrupted.
  • Recompile the assembly from source code and redeploy it to the target directory.
  • Verify file integrity using Get-FileHash "C:\SQLAssemblies\YourAssembly.dll" in PowerShell and compare against a known-good build.

Alternative or Verification Steps

  • Run the CREATE ASSEMBLY statement again from SQL Server Management Studio (SSMS) and confirm it completes without Error 6501; then verify with SELECT * FROM sys.assemblies WHERE name = 'YourAssemblyName';.
  • As an alternative, import the assembly as a binary value directly using CREATE ASSEMBLY ... FROM 0x... (hex byte stream) to bypass file system permission issues entirely.