views:

604

answers:

3

I'm trying to get a WCF Client assembly deploy in SQL 2005. This means I need to create/register the dependencies for my WCF Client, which are:

  • System.Runtime.Serialization
  • System.Web
  • System.ServiceModel

With this script:

CREATE ASSEMBLY System_Runtime_Serialization FROM 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\System.Runtime.Serialization.dll'
WITH PERMISSION_SET = UNSAFE
GO

CREATE ASSEMBLY System_Web FROM 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.dll'
WITH PERMISSION_SET = UNSAFE
GO


CREATE ASSEMBLY System_ServiceModel FROM 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\System.ServiceModel.dll'
WITH PERMISSION_SET = UNSAFE
GO

Registration of System.Web.dll fails with this error message:

Assembly 'System.Web' references assembly 'system.web, version=2.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.', which is not present in the current database. SQL Server attempted to locate and automatically load the referenced assembly from the same location where referring assembly came from, but that operation has failed (reason: version, culture or public key mismatch). Please load the referenced assembly into the current database and retry your request.
A: 

This seems to solve this issue for other people..

I just tried this exact same statement on my SQL Server 2005 SP2 installation and it worked fine. I am guessing that your .NET framework installation especially System.Web is corrupt since it is refering to itself. Can you try it on any other system or try re-installing the .NET framework

This came from MSDN and the person with the original problem said it solved the issue.

Sailing Judo
A: 

just to say... I'm not sure that hosting a WCF client inside SQL-Server is a particularly desirable option. There are some uses of SQL/CLR, for example if you (for whatever reason) want to use bespoke .NET types in the database, or (more likely) you want some very tightly scoped utility methods such as Split, Regex, etc. However, I wouldn't run my main app-logic (such as WCF clients) inside the SQL runtime.

The closest I might get is to have a queue table in the database, and have a windows service dequeue work, process it, and mark it completed (or delete it). This allows you to scale out such work without overloading the database.

I'm sure it might work... I just wouldn't do it myself.

Marc Gravell
What I plan to do is create a CLR function. I need to join data from a webservice with data from SQL Server for use in SQL Server Reporting Services.I know it's possible to do WS calls from SSRS, but they cannot be joined.
Sander Rijken
+3  A: 

OK, figured this out:

I think this happens because I'm on a 64-bit system. I was trying to add the 32-bit version of System.Web to a 64-bit SQL Server (and I think the 32-bit version indeed references the 64-bit version).

Anyway, for reference the working code is below:

CREATE ASSEMBLY System_Runtime_Serialization FROM 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\System.Runtime.Serialization.dll'
WITH PERMISSION_SET = UNSAFE
GO

CREATE ASSEMBLY System_Web FROM 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Web.dll'
WITH PERMISSION_SET = UNSAFE
GO

CREATE ASSEMBLY System_IdentityModel FROM 'c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.IdentityModel.dll'
WITH PERMISSION_SET = UNSAFE
GO
CREATE ASSEMBLY System_IdentityModel_Selectors FROM 'c:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\System.IdentityModel.Selectors.dll'
WITH PERMISSION_SET = UNSAFE
GO

CREATE ASSEMBLY System_Messaging FROM 'c:\windows\Microsoft.net\Framework\v2.0.50727\System.Messaging.dll'
WITH PERMISSION_SET = UNSAFE
GO

CREATE ASSEMBLY System_ServiceModel FROM 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\System.ServiceModel.dll'
WITH PERMISSION_SET = UNSAFE
GO
Sander Rijken
I had to add System.IdentityModel and System.IdentityModel.Selectors from Program Files (x86) to avoid a FileLoadException on System.Runtime.Serialization
Mark Brackett