A .NET Framework error occurred during execution of user-defined routine or aggregat
-
miércoles, 02 de noviembre de 2011 14:53I have a database will all CLR functions, I deploy it to a master database and then the rest of the servers get a backup and restore copy of it. For some reason some functionality works in some servers and not in other ones. I am aware the CLR routines requires external access and that is ok here. The assemblies below had to be manually deployed to make the original database work since I could not figure out how to have them deployed from VS2010 project.Can somebody guide me on how to make the same CLR database function the same accross multiple servers (most of them are Windows 2008 64 bit, couple test machines are Windows 7 64 bit and we have few Windows 7 32 bit)Thanks in advance.IF NOT EXISTS (SELECT * FROM sys.assemblies asms WHERE asms.name = N'System.DirectoryServices' and is_user_defined = 1)CREATE ASSEMBLY [System.DirectoryServices] FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.DirectoryServices.dll'WITH PERMISSION_SET = UNSAFEIF NOT EXISTS (SELECT * FROM sys.assemblies asms WHERE asms.name = N'System.Management' and is_user_defined = 1)CREATE ASSEMBLY [System.Management] FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Management.dll'WITH PERMISSION_SET = UNSAFEIF NOT EXISTS (SELECT * FROM sys.assemblies asms WHERE asms.name = N'Microsoft.Data.Schema.ScriptDom' and is_user_defined = 1)CREATE ASSEMBLY [Microsoft.Data.Schema.ScriptDom] FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Microsoft.Data.Schema.ScriptDom.dll'WITH PERMISSION_SET = UNSAFEIF NOT EXISTS (SELECT * FROM sys.assemblies asms WHERE asms.name = N'Microsoft.Data.Schema.ScriptDom.Sql' and is_user_defined = 1)CREATE ASSEMBLY [Microsoft.Data.Schema.ScriptDom.Sql] FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Microsoft.Data.Schema.ScriptDom.Sql.dll'WITH PERMISSION_SET = UNSAFEMsg 6522, Level 16, State 2, Line 1A .NET Framework error occurred during execution of user-defined routine or aggregate "GetVolumeInfo_CLR":System.IO.FileLoadException: Could not load file or assembly 'System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050) See Microsoft Knowledge Base article 949080 for more information.System.IO.FileLoadException:at UtilClr.FileSystemFunctions.GetVolumeInfo().
Gokhan Varol
Todas las respuestas
-
miércoles, 02 de noviembre de 2011 16:13Moderador
Sounds like it's related to this behavior http://www.sqlskills.com/BLOGS/BOBB/post/Installing-NET-35-on-a-SQL-Server-2005-machinebe-careful.aspx. When using UNSAFE assemblies that are also in the GAC, the version that you compiled your assembly with must match the version in the GAC.
Cheers, Bob
- Marcado como respuesta Bob BeaucheminMVP, Moderator miércoles, 02 de noviembre de 2011 22:17
-
miércoles, 02 de noviembre de 2011 17:15Correct me if I am wrong but I checked the GAC and sys.assemblies and error report, they all seem like they have the same version. Why is the error still reported do you think?SELECT * FROM sys.assemblies showsname principal_id assembly_id clr_name permission_set permission_set_desc is_visible create_date modify_date is_user_definedSystem.Management 1 65562 system.management, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=msil 3 UNSAFE_ACCESS 1 2011-08-16 13:29:02.980 2011-08-16 13:29:02.980 1The error reportsMsg 6522, Level 16, State 2, Line 2A .NET Framework error occurred during execution of user-defined routine or aggregate "GetVolumeInfo_CLR":System.IO.FileLoadException: Could not load file or assembly 'System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Assembly in host store has a different signature than assembly in GAC. (Exception from HRESULT: 0x80131050) See Microsoft Knowledge Base article 949080 for more information.System.IO.FileLoadException:at UtilClr.FileSystemFunctions.GetVolumeInfo()C:\>"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe" /l System.ManagementMicrosoft (R) .NET Global Assembly Cache Utility. Version 3.5.30729.1Copyright (c) Microsoft Corporation. All rights reserved.The Global Assembly Cache contains the following assemblies:System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSILNumber of items = 1
Gokhan Varol -
miércoles, 02 de noviembre de 2011 18:33Moderador
Click on properties or use reflector to get the REAL 4-part version numbers. As an example, although the GAC column reports "2.0.0.0" for the version of System.Management.dll on my machine, right-clicking on the entry, choosing "Properties", and choosing the "Version" tab reports version 2.0.50727.5420.
In general (now watch, someone will find an exception ;-), if the third version number for a 2.0 assembly isn't 50727, you're looking at the wrong info.
Cheers, Bob
-
miércoles, 02 de noviembre de 2011 21:57
I used alter assembly to all my assemblies and it worked :-)
Thank you
ALTER ASSEMBLY [System.DirectoryServices] FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.DirectoryServices.dll'
WITH PERMISSION_SET = UNSAFE
ALTER ASSEMBLY [System.Management] FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Management.dll'
WITH PERMISSION_SET = UNSAFE
GO
ALTER ASSEMBLY [Microsoft.Data.Schema.ScriptDom] FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Microsoft.Data.Schema.ScriptDom.dll'
WITH PERMISSION_SET = UNSAFE
GO
ALTER ASSEMBLY [Microsoft.Data.Schema.ScriptDom.Sql] FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\Microsoft.Data.Schema.ScriptDom.Sql.dll'
WITH PERMISSION_SET = UNSAFE
GO
Gokhan Varol -
martes, 21 de agosto de 2012 14:00
To anyone else out there that might run into this issue, the company that I work for just installed .NET Framework 3.5 and had a similar issue. After a server reboot, our Great Plains credit card encryption software stopped working and users would receive the "A .NET Framework error occurred during execution of user-defined routine or aggregate" error.
Simply running the following alter assembly script on the offending .dll seems to have resolved the issue. Thanks to all those who contributed!
ALTER ASSEMBLY [System.Runtime.Remoting] FROM 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\System.Runtime.Remoting.dll' WITH PERMISSION_SET = UNSAFE

