I don't believe the referenced post is suggesting that the update was corrupt, but rather that portions of the update may not get been fully installed until after a reboot. Some assemblies may have been busy when the update was performed. If this was true, you would have likely discovered this using Reflector and examining your assemblies references.
The fact that you run on your development machine but not the one you are deploying to most likely indicates that the assembly with the version mismatch is environmental and not the actual assembly being deployed. I know I must sound like a broken record (this is my third post on this now), but even if the reboot doesn't fix the problem, I would recommend developing an explanation for the mismatch assembly manifest exception as I feel you'll find your solution in that general direction. Are all of the assemblies that your assembly depends upon have matching version numbers & date/times (in case the version numbers are not being ticked)? Looking at your stack trace it looks like the exception gets thrown out of SqlPerformance counters via way of the trace listener... do you have a custom trace listener? If so, what are it's dependencies? Etc. --Paul Mehner -----Original Message----- From: Discussion of advanced .NET topics. [mailto:[EMAIL PROTECTED] On Behalf Of Efran Cobisi Sent: Tuesday, May 29, 2007 1:45 AM To: ADVANCED-DOTNET@DISCUSS.DEVELOP.COM Subject: Re: [ADVANCED-DOTNET] TypeInitializationException while opening a contextual connection in a SqlServer 2005 deployed assembly Hi Ryan, Actually I've stripped portions of my code because I thought it was irrelevant (I hope so at least). In fact, the contextual connection is opened inside the method you mentioned, which in turns get called by the method I've reported the code of; for simplicity I've removed the call (and the method) and moved the relevant portion of code inside that method. My tests confirm, however, that irrelevancy. Btw I've found this post [1] in Microsoft forums, which talks about restarting the machine (a corrupted update?); so, I'm going to try this in the server "mainteinance window" time. Unfortunately the code I've posted actually seems to work in my development and staging server machine but not in the production one. When one says Murphy's law... [1] http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1104113&SiteID=1 I will let you know what will happen after restarting. Thanks. -- Efran Cobisi http://www.cobisi.com Ryan Heath wrote: > Hi, > > What is the code like at > ***.UserDefinedFunctions.ResolveCmsReference(String assetId) ? > > It seems you opened another connection to the database? > > // Ryan > > On 5/28/07, Efran Cobisi <[EMAIL PROTECTED]> wrote: >> 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(r) http://www.develop.com >> >> View archives and manage your subscription(s) at >> http://discuss.develop.com >> > > =================================== > This list is hosted by DevelopMentorR http://www.develop.com > > View archives and manage your subscription(s) at > http://discuss.develop.com =================================== This list is hosted by DevelopMentorR http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com =================================== This list is hosted by DevelopMentorĀ® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com