WCF Client Inside SQL CLR

I know this is not supported, and I know that this is not even a good idea. But I want the WCF client to be inside the value of the SQL table table.

I (apparently) registered the correct assemblies, but when I start my client - I get a WCF error:

Msg 6522, Level 16, State 1, Line 1
System.ServiceModel.CommunicationObjectFaultedException: 
 The communication object, System.ServiceModel.ChannelFactory`1 [MyProxy.IMyService], 
 cannot be used for communication because it is in the Faulted state.

Testing outside the Sql server seems to have worked - and I don’t even see the WCF client trying to establish a TCP connection.

Not sure if this is a WCF or SQL CLR issue, since I'm new to both.

Edit: I understand that the required System.ServiceModel and its many assemblies are outside of the proven Sql CLR list. However

"Unsupported libraries can still be called from managed stored procedures, triggers, user-defined functions, user-defined types, and user-defined aggregates. An unsupported library must first be registered in the SQL Server database using CREATE ASSEMBLY before it can be used in your code "Any unsupported library that is registered and running on the server must be checked and verified for security and reliability."

+2
source share
5 answers
+4

, Kev, , . WCF- - CommunicationObjectFaultedException, - VS2008 ( ?).

FileLoadException, System.ServiceModel:

- , GAC. ( HRESULT: 0x80131050) . 949080 .

, KB 949080 , SQL 2005 ( , SQL 2008 2005 - , ) .NET FX - .

32- 64- . SQL 2008 - x64 2008 x64 - , , C:\Windows\Microsoft.NET\Framework, Framework64. SQL Server - 64- , - Framework64 System.IdentityModel System.IdentityModel.Selectors Program Files, Program Files (x86).

, x86 - System.Web :

Assembly 'System.Web' assembly assembly 'system.web, version = 2.0.0.0, culture = neutral, publickeytoken = b03f5f7f11d50a3a.', .

, ... , System.Web, , System.Web. , StackOverflow . , , Framework64 System.Web Framework .

, , WCF, CommunicationObjectFaultedException. WCF IDisposable, use Dispose, - - :

var p = new MyServiceClient(new CustomBinding(b), new EndpointAddress(uri));
var result = p.Execute(); // Don't Dispose proxy or you'll lose the actual exception.

try {
   return result.Values;
} finally {
   if (p.State != CommunicationState.Closed) {
      if (p.State != CommunicationState.Faulted) {
         p.Close();
      } else {
         p.Abort();
      }
   }
}

FileLoadException, System.Runtime.Serialization KB 949080.

, x64 , , Framework, , , Program Files (x86) System.IdentityModel.

- ... . IntPtr.Size 8 ... x64. x64 ( x86) - ​​ AnyCPU. x86 x64, , . CREATE ASSEMBLIES:
create assembly [System.Web] 
from 'C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Web.dll'
with permission_set = UNSAFE

create assembly [System.Messaging] 
from 'C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Messaging.dll'
with permission_set = UNSAFE

create assembly [SMDiagnostics]
from 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\SMDiagnostics.dll'
with permission_set = UNSAFE

CREATE ASSEMBLY [System.IdentityModel] 
from 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.IdentityModel.dll'
with permission_set = UNSAFE

CREATE ASSEMBLY [System.IdentityModel.Selectors] 
from 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.0\System.IdentityModel.Selectors.dll'
with permission_set = UNSAFE

CREATE ASSEMBLY [Microsoft.Transactions.Bridge] 
from 'C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\Microsoft.Transactions.Bridge.dll'
with permission_set = UNSAFE

AnyCPU. YMMV x86- Sql Server.

. , . C.

+3

, SQL Server 2005 SQL CLR. , WCF . , , SQL CLR 2008 .

: http://support.microsoft.com/kb/922672

0

- WCF SQL CLR. .NET, .

, WebClient, HTTP- WCF, , , SQL Server.

0

System.Runtime.Serialization. x64

Solution: find System.Runtime.Serialization in the c: \ windows \ assembly directory, copy it to another directory and run the CREATE ASSEMBLY sql command.

Best

0
source

All Articles