MSSQLSERVER_6522MSSQLSERVER_6522
Se aplica a:Applies to: SQL ServerSQL Server (todas las versiones admitidas)
SQL ServerSQL Server (all supported versions)
SQL ServerSQL Server (todas las versiones admitidas)
SQL ServerSQL Server (all supported versions)
DetallesDetails
AtributoAttribute | ValueValue |
---|---|
Nombre de productoProduct Name | SQL ServerSQL Server |
Id. de eventoEvent ID | 65226522 |
Origen de eventosEvent Source | MSSQLSERVERMSSQLSERVER |
ComponenteComponent | SQLEngineSQLEngine |
Nombre simbólicoSymbolic Name | SQLCLR_UDF_EXEC_FAILEDSQLCLR_UDF_EXEC_FAILED |
Texto del mensajeMessage Text | Error de .NET Framework durante la ejecución de la rutina o agregado definido por el usuario "%.*ls": %ls.A .NET Framework error occurred during execution of user defined routine or aggregate "%.*ls": %ls. |
ExplicaciónExplanation
Considere los siguientes escenarios.Consider the following scenarios.
Escenario 1Scenario 1
Cree una rutina de Common Language Runtime (CLR) que haga referencia a un ensamblado de Microsoft .NET Framework.You create a common language runtime (CLR) routine that references a Microsoft .NET Framework assembly. El ensamblado de .NET Framework no se documenta en 922672.The .NET Framework assembly is not documented in 922672. A continuación, instale la corrección basada en .NET Framework 3.5 o en .NET Framework 2.0.Then, you install the .NET Framework 3.5 or a .NET Framework 2.0-based hotfix.
Escenario 2Scenario 2
Cree un ensamblado y, a continuación, registre el ensamblado en una base de datos SQL ServerSQL Server.You create an assembly, and then you register the assembly in a SQL ServerSQL Server database. A continuación, instale una versión diferente del ensamblado en la caché global de ensamblados (GAC).Then, you install a different version of the assembly in the Global Assembly Cache (GAC).
Al ejecutar la rutina de CLR o usar el ensamblado de cualquiera de estos escenarios en SQL ServerSQL Server, recibirá un mensaje de error similar al siguiente:When you execute the CLR routine or use the assembly from either of these scenarios in SQL ServerSQL Server, you receive an error message that resembles the following:
Servidor: Mensaje 6522, nivel 16, estado 2, línea 1Server: Msg 6522, Level 16, State 2, Line 1
Error de .NET Framework durante la ejecución de la rutina o agregado definido por el usuario "getsid":A .NET Framework error occurred during execution of user defined routine or aggregate 'getsid':System.IO.FileLoadException: No se puede cargar el archivo o ensamblado 'System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ni una de sus dependencias.System.IO.FileLoadException: Could not load file or assembly 'System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. El ensamblado del almacén de host tiene una signatura diferente a la del ensamblado de GAC.Assembly in host store has a different signature than assembly in GAC. (Excepción de HRESULT: 0x80131050)(Exception from HRESULT: 0x80131050)
Causa posiblePossible cause
Cuando CLR carga un ensamblado, CLR comprueba que el mismo ensamblado se encuentra en la GAC.When the CLR loads an assembly, the CLR verifies that the same assembly is in the GAC. Si el mismo ensamblado se encuentra en la GAC, CLR comprueba que los identificadores de versión del módulo (MVID) de estos ensamblados coinciden.If the same assembly is in the GAC, the CLR verifies that the Module Version IDs (MVIDs) of these assemblies match. Si los MVID de estos ensamblados no coinciden, recibirá el mensaje de error que se menciona en la sección Explicación.If the MVIDs of these assemblies do not match, you receive the error message that the Explanation section mentions.
Cuando se vuelve a compilar un ensamblado, cambia el MVID del mismo.When an assembly is recompiled, the MVID of the assembly changes. Por lo tanto, si actualiza el .NET Framework, los ensamblados de .NET Framework tienen MVID diferentes porque esos ensamblados se vuelven a compilar.Therefore, if you update the .NET Framework, the .NET Framework assemblies have different MVIDs because those assemblies are recompiled. Además, si actualiza su propio ensamblado, este se volverá a compilar.Additionally, if you update your own assembly, the assembly is recompiled. Por lo tanto, el ensamblado también tiene un MVID diferente.Therefore, the assembly also has a different MVID.
Acción del usuarioUser action
Acción 1Action 1
Para solucionar el escenario 1 de la sección Explicación, debe actualizar manualmente los ensamblados de .NET Framework en SQL ServerSQL Server.To work around scenario 1 in the Explanation section, you must manually update the .NET Framework assemblies in SQL ServerSQL Server. Para ello, use la instrucción ALTER ASSEMBLY
de modo que apunte a la nueva versión del ensamblado de .NET Framework en la siguiente carpeta:To do this, use the ALTER ASSEMBLY
statement to point to the new version of the .NET Framework assembly in the following folder:
%Windir%\Microsoft.NET\Framework\Version
Nota
Versión representa la versión de .NET Framework que instaló o actualizó.Version represents the version of the .NET Framework that you installed or updated.
Acción 2Action 2
Para solucionar el escenario 2 de la sección Explicación, utilice la instrucción ALTER ASSEMBLY
para actualizar el ensamblado en la base de datos.To work around scenario 2 in the Explanation section, use the ALTER ASSEMBLY
statement to update the assembly in the database.
Si el problema sigue existiendo después de hacerlo, coloque el ensamblado de la base de datos y, a continuación, registre la nueva versión del ensamblado en la base de datos.If the problem still exists after you do this, drop the assembly from the database, and then register the new version of the assembly in the database.
Más informaciónMore information
No se recomienda usar ensamblados de .NET Framework que no estén documentados en Directiva de soporte técnico para los ensamblados de .NET Framework que no se hayan probado en el entorno alojado en CLR de SQL Server.We do not recommend that you use .NET Framework assemblies that are not documented in Support policy for untested .NET Framework assemblies in the SQL Server CLR-hosted environment. Muestra los ensamblados que se prueban en el entorno alojado en CLR de SQL ServerSQL Server.It lists the assemblies that are tested in the SQL ServerSQL Server CLR-hosted environment.
Descripción de las rutinas CLRDescription of CLR routines
Las rutinas CLR incluyen los siguientes objetos que se implementan mediante la integración de SQL ServerSQL Server con CLR de .NET Framework:CLR routines include the following objects that are implemented by using SQL ServerSQL Server integration with the .NET Framework CLR:
- Funciones definidas por el usuario con valores escalares (UDF escalares)Scalar-valued user-defined functions (scalar UDFs)
- Funciones definidas por el usuario con valores de tabla (TVF)Table-valued user-defined functions (TVFs)
- Procedimientos definidos por el usuario (UDP)User-defined procedures (UDPs)
- Desencadenadores definidos por el usuarioUser-defined triggers
- Tipos de datos definidos por el usuarioUser-defined data types
- Agregados definidos por el usuarioUser-defined aggregates
Ensamblados que se van a actualizar después de instalar .NET Framework 3.5Assemblies to update after you install the .NET Framework 3.5
Después de instalar .NET Framework 3.5, debe usar la instrucción ALTER ASSEMBLY para actualizar los siguientes ensamblados:After you install the .NET Framework 3.5, you must use the ALTER ASSEMBLY statement to update the following assemblies:
- Accessibility.dllAccessibility.dll
- AspNetMMCExt.dllAspNetMMCExt.dll
- Cscompmgd.dllCscompmgd.dll
- IEExecRemote.dllIEExecRemote.dll
- IEHost.dllIEHost.dll
- IIEHost.dllIIEHost.dll
- Microsoft.Build.Conversion.dllMicrosoft.Build.Conversion.dll
- Microsoft.Build.Engine.dllMicrosoft.Build.Engine.dll
- Microsoft.Build.Framework.dllMicrosoft.Build.Framework.dll
- Microsoft.Build.Tasks.dllMicrosoft.Build.Tasks.dll
- Microsoft.Build.Utilities.dllMicrosoft.Build.Utilities.dll
- Microsoft.CompactFramework.Build.Tasks.dllMicrosoft.CompactFramework.Build.Tasks.dll
- Microsoft.JScript.dllMicrosoft.JScript.dll
- Microsoft.VisualBasic.Vsa.dllMicrosoft.VisualBasic.Vsa.dll
- Microsoft.Vsa.dllMicrosoft.Vsa.dll
- Microsoft.Vsa.Vb.CodeDOMProcessor.dllMicrosoft.Vsa.Vb.CodeDOMProcessor.dll
- Microsoft_VsaVb.dllMicrosoft_VsaVb.dll
- Sysglobl.dllSysglobl.dll
- System.Configuration.Install.dllSystem.Configuration.Install.dll
- System.Design.dllSystem.Design.dll
- System.DirectoryServices.dllSystem.DirectoryServices.dll
- System.DirectoryServices.Protocols.dllSystem.DirectoryServices.Protocols.dll
- System.Drawing.dllSystem.Drawing.dll
- System.Drawing.Design.dllSystem.Drawing.Design.dll
- System.EnterpriseServices.dllSystem.EnterpriseServices.dll
- System.Management.dllSystem.Management.dll
- System.Messaging.dllSystem.Messaging.dll
- System.Runtime.Serialization.Formatters.Soap.dllSystem.Runtime.Serialization.Formatters.Soap.dll
- System.ServiceProcess.dllSystem.ServiceProcess.dll
- System.Web.dllSystem.Web.dll
- System.Web.Mobile.dllSystem.Web.Mobile.dll
- System.Web.RegularExpressions.dllSystem.Web.RegularExpressions.dll
Estos ensamblados se encuentran en la siguiente carpeta:These assemblies are in the following folder:
%Windir%\Microsoft.NET\Framework\v2.0.50727
Cómo conservar los datos de los tipos de datos definidos por el usuario después de colocar un ensambladoHow to preserve the data from user-defined data types after you drop an assembly
Si coloca un ensamblado que usa un tipo de datos definido por el usuario de SQL ServerSQL Server, puede utilizar uno de los métodos siguientes para conservar los datos.If you drop an assembly that a user-defined data type from SQL ServerSQL Server uses, you can use one of the following methods to preserve the data.
Supongamos que lo siguiente es el escenario:Assume that the following is the scenario:
- Cree un ensamblado cuyo nombre sea MyAssembly.dllYou create an assembly whose name is MyAssembly.dll.
- El ensamblado MyAssembly hace referencia al ensamblado
System.DirectoryServices.dll
.The MyAssembly assembly references theSystem.DirectoryServices.dll
assembly. - Tiene un tipo de datos definido por el usuario cuyo nombre es MyDateTime.You have a user-defined data type whose name is MyDateTime.
- El tipo de datos MyDateTime utiliza el ensamblado MyAssembly.dll.The MyDateTime data type uses the MyAssembly.dll assembly.
- Cree una tabla cuyo nombre sea MyTable.You create a table whose name is MyTable.
- La tabla MyTable contiene los datos del tipo de datos MyDateTime.The MyTable table contains the data of the MyDateTime data type.
Método 1: Uso de la utilidad bcp.exeMethod 1: Use the bcp.exe utility
Use la utilidad Bcp.exe junto con el modificador -n para copiar los datos de la tabla MyTable en un archivo.Use the Bcp.exe utility together with the -n switch to copy the data from the MyTable table into a file. Por ejemplo, ejecute el comando siguiente en el símbolo del sistema:For example, run the following command at a command prompt:
bcp MyDatabase.dbo.MyTable out C:\MyFile.bcp -n -SSQLServerName -T
En SQL ServerSQL Server Management Studio, siga estos pasos:In SQL ServerSQL Server Management Studio, follow these steps:
- Coloque la tabla MyTable.Drop the MyTable table.
- Coloque el tipo de datos MyDateTime.Drop the MyDateTime data type.
- Coloque el ensamblado
System.DirectoryServices.dll
.Drop theSystem.DirectoryServices.dll
assembly. - Coloque el ensamblado MyAssembly.Drop the MyAssembly assembly.
En SQL ServerSQL Server Management Studio, siga estos pasos:In SQL ServerSQL Server Management Studio, follow these steps:
- Registre el ensamblado
System.DirectoryServices.dll
.Register theSystem.DirectoryServices.dll
assembly. - Registre el ensamblado MyAssembly.Register the MyAssembly assembly.
- Cree el tipo de datos MyDateTime.Create the MyDateTime data type.
- Cree una nueva tabla que tenga la misma estructura de tabla que la tabla MyTable.Create a new table that has the same table structure as the MyTable table.
- Registre el ensamblado
Use la utilidad Bcp.exe junto con el modificador -n para importar los datos del archivo en la tabla MyTable.Use the Bcp.exe utility together with the -n switch to import the data from the file into the MyTable table. Por ejemplo, ejecute el comando siguiente en el símbolo del sistema:For example, run the following command at a command prompt:
bcp MyDatabase.dbo.MyTable in C:\MyFile.bcp -n -SSQLServerName -T
Método 2: Uso de la instrucción INSERT... Instrucción SELECTMethod 2: Use the INSERT ... SELECT statement
Supongamos que el tipo de datos MyDateTime ocupa 9 bytes en el almacenamiento.Assume that the MyDateTime data type occupies 9 bytes in storage.
En SQL ServerSQL Server Management Studio, cree una nueva tabla que contenga una columna del tipo de datos
VARBINARY(9)
mediante la ejecución de la siguiente instrucción:In SQL ServerSQL Server Management Studio, create a new table that contains a column of theVARBINARY(9)
data type by running the following statement:CREATE TABLE TempTable (c1 VARBINARY(9));
Ejecute la siguiente instrucción INSERT... Instrucción SELECT para rellenar la tabla TempTable:Run the following INSERT ... SELECT statement to populate the TempTable table:
INSERT INTO TempTable SELECT CAST(c1 as VARBINARY(9)) FROM MyTable;
En SQL ServerSQL Server Management Studio, siga estos pasos:In SQL ServerSQL Server Management Studio, follow these steps:
- Coloque la tabla MyTable.Drop the MyTable table.
- Coloque el tipo de datos MyDateTime.Drop the MyDateTime data type.
- Coloque el ensamblado System.DirectoryServices.dll.Drop the System.DirectoryServices.dll assembly.
- Coloque el ensamblado MyAssembly.Drop the MyAssembly assembly.
En SQL ServerSQL Server Management Studio, siga estos pasos:In SQL ServerSQL Server Management Studio, follow these steps:
- Registre el ensamblado System.DirectoryServices.dll.Register the System.DirectoryServices.dll assembly.
- Registre el ensamblado MyAssembly.Register the MyAssembly assembly.
- Cree el tipo de datos MyDateTime.Create the MyDateTime data type.
- Cree una nueva tabla que tenga la misma estructura de tabla que la tabla MyTable.Create a new table that has the same table structure as the MyTable table.
Ejecute la siguiente instrucción INSERT... Instrucción SELECT para rellenar la tabla MyTable:Run the following INSERT ... SELECT statement to populate the MyTable table:
INSERT INTO MyTable SELECT c1 FROM TempTable;
ReferenciasReferences
- Para obtener más información sobre la versión del ensamblado, consulte la documentación retirada de Visual Studio 2005.For more information about the assembly version, see Visual Studio 2005 Retired documentation.
- Para obtener más información sobre cómo actualizar un ensamblado, consulte ALTER ASSEMBLY (Transact-SQL).For more information about how to update an assembly, see ALTER ASSEMBLY (Transact-SQL).
- Para obtener más información sobre cómo colocar un ensamblado, consulte DROP ASSEMBLY (Transact-SQL).For more information about how to drop an assembly, see DROP ASSEMBLY (Transact-SQL).
- Para obtener más información sobre cómo registrar un ensamblado en una base de datos de SQL ServerSQL Server, consulte CREATE ASSEMBLY (Transact-SQL)For more information about how to register an assembly in a SQL ServerSQL Server database, see CREATE ASSEMBLY (Transact-SQL).
- Para más información acerca de la utilidad Bcp.exe, consulte https://msdn2.microsoft.com/library/ms162802.aspx.For more information about the Bcp.exe utility, see https://msdn2.microsoft.com/library/ms162802.aspx.