.NET Maui iOS build error using Microsoft.Data.SqlClient

Kurt K 176 Reputation points
2022-11-23T01:19:51.607+00:00

In my .NET Maui project, I need to connect to a Sql Server database over local network connections only (NOT over the Internet).

I am using Microsoft.Data.SqlClient. The Windows platform builds and runs fine.

The iOS build results in the following error:

Error clang++ exited with code 1:
ld: framework not found System
... Xamarin.Shared.Sdk.targets

I had been successful using System.Data.SqlClient, but I wanted to use Microsoft.Data.SqlClient since it is now the recommended SqlClient.

Please let me know how to get local network connections to a Sql Server database working in .NET Maui.

Thank you.

Developer technologies .NET .NET MAUI
{count} votes

Accepted answer
  1. Wenyan Zhang (Shanghai Wicresoft Co,.Ltd.) 36,436 Reputation points Microsoft External Staff
    2022-12-01T03:00:56.46+00:00

    Hello @Kurt K ,

    I check the Microsoft.Data.SqlClient and System.Data.SqlClient NuGet package, they are not supported for .net Windows and .net iOS (The Compatible target framework(s) don't include .net Windows and .net iOS)
    You can make web services so that the APP sends requests and receives the response from the web service. This doc (Consume a REST-based web service) is about how to use it in client side, you also should create web services on the server side. For the further support about server side, you can create a new thread.
    In addition, it's recommended that you use SQLite (but not SQL server) with iOS and Android to store and retrieve objects, please see .NET MAUI local databases - .NET MAUI | Microsoft Learn

    can we rely on it remaining a part of .NET Maui, at least for a while, even though it is not officially supported?

    Yes, you can keep using System.Data.SqlClient if it works. If you have any other issues, please feel free to post here.

    Best Regards,
    Wenyan Zhang


    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.