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 DevelopMentorĀ®  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

Reply via email to