Hi all, I'm trying to have a managed assembly working properly after being deployed to an instance of SqlServer 2005. Unfortunately, whenever I call a particular user defined function which maps to a method of this assembly, which in turns open a new contextual connection, a weird exception is thrown. I've already googled a bit and I found this kind of exception could be related to an invalid configuration file for the application; unfortunately there's no configuration file deployed with this assembly.
Here is the full exception details: ----------- A .NET Framework error occurred during execution of user-defined routine or aggregate "ResolveCmsReferences": System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlConnectionFactory' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Data.SqlClient.SqlPerformanceCounters' threw an exception. ---> System.IO.FileLoadException: The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) System.IO.FileLoadException: at System.Diagnostics.Switch.InitializeWithStatus() at System.Diagnostics.Switch.get_SwitchSetting() at System.Diagnostics.TraceSwitch.get_Level() at System.Data.ProviderBase.DbConnectionPoolCounters..ctor(String categoryName, String categoryHelp) at System.Data.SqlClient.SqlPerformanceCounters..ctor() at System.Data.SqlClient.SqlPerformanceCounters..cctor() System.TypeInitializationException: at System.Data.SqlClient.SqlConnectionFactory..ctor() at System.Data.SqlClient.SqlConnectionFactory..cctor() System.TypeInitializationException: at System.Data.SqlClient.SqlConnection..cctor() System.TypeInitializationException: at System.Data.SqlClient.SqlConnection..ctor(String connectionString) at ***.UserDefinedFunctions.ResolveCmsReference(String assetId) at ***.UserDefinedFunctions.CmsImageMatchEvaluator(Match maCurrent) at System.Text.RegularExpressions.RegexReplacement.Replace(MatchEvaluator evaluator, Regex regex, String input, Int32 count, Int32 startat) at System.Text.RegularExpressions.Regex.Replace(String input, MatchEvaluator evaluator, Int32 count, Int32 startat) at System.Text.RegularExpressions.Regex.Replace(String input, MatchEvaluator evaluator) at ***.UserDefinedFunctions.ResolveCmsReferences(SqlString sqlInput) . The statement has been terminated. ----------- The method which actually throws the exception is this one (I've omitted the irrelevant lines of code): ----------- [SqlFunction] public static SqlString ResolveCmsReferences(SqlString sqlInput) { // strip... using (SqlConnection connContext = new SqlConnection("context connection=true")) { // The following line is throwing the aforementioned exception connContext.Open(); // strip... } // strip... } ----------- The SQLCLR assembly has been deployed with an EXTERNAL ACCESS permission level. Any help would be very appreciated. Thanks. -- Efran Cobisi http://www.cobisi.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com