Search

Unable to create assembly System.Net.Http (v4.0) in Sql Server 2012 x64 by Andy Fenna

Closed
as By Design Help for as By Design

1
0
Sign in
to vote
Type: Bug
ID: 777239
Opened: 1/23/2013 2:35:37 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
When trying to create an assembly reference for System.Net.Http using sql commands, I get an error (db trustworthy parameter is set and EXTERNAL ACCESS/UNSAFE assembly permissions have been granted to user)

This is the tsql i have ran:-

USE master
GO

CREATE ASYMMETRIC KEY CLRBuildInfoKey
FROM FILE = 'C:\temp\BuildInfo\BuildInfo.snk'
ENCRYPTION BY PASSWORD = '@Str0ngP@$$w0rd'
GO

CREATE LOGIN CLRBuildInfoLogin FROM ASYMMETRIC KEY CLRBuildInfoKey;
GRANT UNSAFE ASSEMBLY TO CLRBuildInfoLogin;
GO

ALTER DATABASE BuildInfo
SET TRUSTWORTHY ON
GO

USE BuildInfo
GO

CREATE USER CLRBuildInfo FOR LOGIN CLRBuildInfoLogin
GO

CREATE ASSEMBLY [System.Net.Http]
    AUTHORIZATION [CLRBuildInfo]
    FROM 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll'
    WITH PERMISSION_SET = UNSAFE;
GO

Produces this error:-

Warning: The Microsoft .NET Framework assembly 'system.net.http, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.' you are registering is not fully tested in the SQL Server hosted environment and is not supported. In the future, if you upgrade or service this assembly or the .NET Framework, your CLR integration routine may stop working. Please refer SQL Server Books Online for more details.
Msg 6218, Level 16, State 2, Line 1
CREATE ASSEMBLY for assembly 'System.Net.Http' failed because assembly 'System.Net.Http' failed verification. Check if the referenced assemblies are up-to-date and trusted (for external_access or unsafe) to execute in the database. CLR Verifier error messages if any will follow this message
[ : System.Net.Http.SR::.ctor][mdToken=0x6000001][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_ResourceManager][mdToken=0x6000002][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_Culture][mdToken=0x6000003][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::set_Culture][mdToken=0x6000004][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_net_http_argument_empty_string][mdToken=0x6000005][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_net_http_client_absolute_baseaddress_required][mdToken=0x6000006][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_net_http_client_content_headers][mdToken=0x6000007][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_net_http_client_execution_error][mdToken=0x6000008][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_net_http_client_http_baseaddress_required][mdToken=0x6000009][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_net_http_client_invalid_requesturi][mdToken=0x600000a][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_net_http_client_request_already_sent][mdToken=0x600000b][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_net_http_client_request_headers][mdToken=0x600000c][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_net_http_client_response_headers][mdToken=0x600000d][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_net_http_client_send_canceled][mdToken=0x600000e][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_net_http_client_send_completed][mdToken=0x600000f][offset 0x00000000] Code size is zero.
[ : System.Net.Http.SR::get_net...

Details (expand)

Product Language

English

Version

SQL Server 2012 SP1

Category

SQL Engine

Operating System

Windows 7 Professional

Operating System Language

English

Steps to Reproduce

This is the tsql i have ran to reproduce the problem:-

CREATE ASYMMETRIC KEY CLRBuildInfoKey
FROM FILE = 'C:\temp\BuildInfo\BuildInfo.snk'
ENCRYPTION BY PASSWORD = '@Str0ngP@$$w0rd'
GO

CREATE LOGIN CLRBuildInfoLogin FROM ASYMMETRIC KEY CLRBuildInfoKey;
GRANT UNSAFE ASSEMBLY TO CLRBuildInfoLogin;
GO

ALTER DATABASE BuildInfo
SET TRUSTWORTHY ON
GO

USE BuildInfo
GO

CREATE USER CLRBuildInfo FOR LOGIN CLRBuildInfoLogin
GO

CREATE ASSEMBLY [System.Net.Http]
    AUTHORIZATION [CLRBuildInfo]
    FROM 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.Net.Http.dll'
    WITH PERMISSION_SET = UNSAFE;
GO

Actual Results

The error in the description is produced.

Expected Results

The dll must be integrated successfully.

Platform

X64

Virtualization

 
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 1/30/2013 at 6:06 PM
I believe this is by-design. You should not be using the reference assembly..

Instead, please try the real assembly:

CREATE ASSEMBLY [System.Net.Http]
AUTHORIZATION [CLRBuildInfo]
FROM 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Net.Http.dll'
WITH PERMISSION_SET = UNSAFE;
GO

Although, I still observe that this is not supported by SQL Server:

"Warning: The Microsoft .NET Framework assembly 'system.net.http, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a, processorarchitecture=msil.' you are registering is not fully tested in the SQL Server hosted environment and is not supported. In the future, if you upgrade or service this assembly or the .NET Framework, your CLR integration routine may stop working. Please refer SQL Server Books Online for more details."
Sign in to post a workaround.