Troubleshooting Guide: Microsoft SQL Server Error 6941 – “Invalid Type Definition”
Why This Error Happens
Error 6941 typically occurs when SQL Server encounters a corrupted or malformed CLR (Common Language Runtime) user-defined type (UDT) definition within the database metadata. This can result from an incomplete assembly deployment, a mismatch between the assembly version registered in SQL Server and the actual DLL on disk, or corruption in the system catalog views (sys.assemblies, sys.types) following an improper upgrade from a previous SQL Server version. In Windows Server 2025 environments, this is also frequently triggered by .NET runtime version conflicts after a Windows Update patches the CLR hosting environment.
Step-by-Step Resolution Guide
Step 1: Verify the CLR Assembly Integrity
- Open SQL Server Management Studio (SSMS) and run
SELECT * FROM sys.assemblies WHERE name = 'YourAssemblyName';to confirm the assembly is registered. - Check the physical DLL path (commonly under
C:\Program Files\Microsoft SQL Server\MSSQL17.MSSQLSERVER\MSSQL\Binn\) to ensure the file has not been deleted, renamed, or replaced with an incompatible version. - Run
SELECT assembly_class, assembly_method FROM sys.assembly_types WHERE assembly_id = <id>;to cross-reference the type definitions against the assembly.
Step 2: Rebuild or Redeploy the User-Defined Type
- Drop the affected type using
DROP TYPE dbo.YourTypeName;(ensure no dependent objects exist first by checkingsys.sql_dependencies). - Drop and re-add the assembly:
DROP ASSEMBLY YourAssemblyName; CREATE ASSEMBLY YourAssemblyName FROM 'C:\Path\To\YourAssembly.dll' WITH PERMISSION_SET = SAFE; - Recreate the type definition:
CREATE TYPE dbo.YourTypeName EXTERNAL NAME YourAssemblyName.[Namespace.ClassName];
Step 3: Check .NET Runtime Compatibility on Windows Server 2025
- Navigate to Control Panel > Programs > Programs and Features and confirm the correct .NET Framework version (4.8.1 or higher) is installed alongside .NET 9 runtime components required by SQL Server 2025.
- If a mismatch exists, repair the .NET installation via
dotnet repairor reinstall the specific runtime from the Microsoft .NET download page. - Restart the SQL Server service via
services.mscor runnet stop MSSQLSERVER && net start MSSQLSERVERin an elevated Command Prompt.
Step 4: Run Database Consistency Checks
- Execute
DBCC CHECKDB('YourDatabaseName') WITH NO_INFOMSGS, ALL_ERRORMSGS;to scan for underlying catalog corruption. - If corruption is found in system tables, restore the database from the last known good backup rather than attempting an in-place repair, as
REPAIR_ALLOW_DATA_LOSSdoes not reliably fix CLR type metadata.
Alternative or Verification Steps
- To verify the fix, run the original query or stored procedure that triggered Error 6941 and confirm it executes without exceptions; also re-check
sys.assembly_typesto ensure the type resolves correctly. - If the error persists, as an alternative, export the data using
bcpor SSIS to a new database with freshly created (non-CLR) native data types, bypassing the corrupted UDT entirely.