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.

Ok, I've finally tested this issue with Reflector but every assembly
reference is fine. By the way, I'm just using System.Data.dll and
System.Xml.dll; references of this assemblies are fine too.
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)?
Sure.

 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?
Sorry, no custom trace listener.
 If so, what are it's dependencies? Etc.

--Paul Mehner


I'm going to reboot and see what will happen.
Thanks.

--
Efran Cobisi
http://www.cobisi.com



-----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




--
Efran Cobisi
Solution developer

*cobisi.com* - /object oriented breeze/
*Padova* [Head office] - Ph. +39.0497966390 - Fax +39.0497964967
*Bologna* - Ph. +39.0510546290



The contents of this e-mail are intended for the named addressee only.
It contains information that may be confidential. Unless you are the
named addressee or an authorized designee, you may not copy or use it,
or disclose it to anyone else. If you received it in error please notify
us immediately and then destroy it.

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to