Assembly 'system.net.http, version=4.0.0.0' was not found in the SQL catalog error

Nguyen, David V 1 Reputation point
2024-03-29T14:32:39.2433333+00:00

I created a SQL C# CLR Stored Procedure project and when trying to publish it the SQL Server (15.0.4335.1) I got this error:

(47,1): SQL72014: .Net SqlClient Data Provider: Msg 6503, Level 16, State 12, Line 1 Assembly 'system.net.http, version=4.0.0.0, culture=neutral, publickeytoken=b03f5f7f11d50a3a.' was not found in the SQL catalog.

(47,0): SQL72045: Script execution error. The executed script:

CREATE ASSEMBLY [FUSEAutomation]

AUTHORIZATION [dbo]
An error occurred while the batch was being executed.

I write c# code with these references:


powershell
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Net.Http;
using System.Net.Http.Headers;
using System.ComponentModel.DataAnnotations;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json;

I am using HttpClient class to call web api.

Am I not using the right version of System.Net.Http? If so what is the verion should I be

using? I am using Visual Studio 2017.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,718 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Erland Sommarskog 101K Reputation points MVP
    2024-03-29T15:27:11.9933333+00:00

    Not all .NET libraries are directly supported in SQL Server. See this Learn topic for a list of supported libraries/namespaces. System.Net is not among those.

    As discussed in the same topic, you can still use these unsupported libraries, but you need to load them with CREATE ASSEMBLY.


  2. LucyChen-MSFT 965 Reputation points Microsoft Vendor
    2024-04-05T03:07:05.35+00:00

    Hi @Nguyen, David V,

    I checked the error messages you provided in comments. Just like Erland said, 'it is not really apt for beginners.'. However, I’ve found an issue similar to yours, hope this can help you well.User's image

    Anyway, it’s always good to try and explore hard. Hope your issue will be solved well.

    Best regards,

    Lucy Chen


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    https://docs.microsoft.com/en-us/answers/support/email-notifications

    0 comments No comments