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,914 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Erland Sommarskog 102.4K Reputation points
    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. LucyChenMSFT-4874 1,580 Reputation points
    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


  3. Samyn Axel 0 Reputation points
    2024-05-16T08:53:59.3233333+00:00

    I encountered the same issue.

    After reading some more posts, I realized that the .NET version used by SQL Server is fixed for a certain SQL Server Version. That means that for my SQL Server 2014, I had to use .NET Framework 4.0 and the libraries that are available in that framework to make things work.

    I asked chatgpt about your particular version (SQL Server 2019) and found that it had to use .NET Framework 4.6.

    If I remember correctly, System.Net.Http was introduced starting .NET Framework 4.5 so you should be able to reference that namespace, but I guess you'll still have to add the assembly to your SQL Server which is a step i did not have to, since I used older classes built in more classic assemblies (System.Net) to achieve my network queries.

    I hope this will help you find a solution !

    0 comments No comments