SqlException: System.Net.Security.Native

I’m receiving this error in unity while trying to connect to my SQL Database. I’m assuming that it has something to do with a missing dll but I’m not sure. Can anyone explain to me what this error is indicating and what I need to do to fix it?

Hi, did you fix it yet?
I have the same problem.

No, we can’t tell you what’s wrong since we have almost no information at all besides that stacktrace snippet as an image. First of all, are you actually trying to connect to a MsSQL server (A Microsoft SQL server, not a MySQL server)? The System.Data.SqlClient namespace is only for Microsoft SQL servers. If you’re trying to connect to a MySQL server you need the MySQL connector which has it’s own seperate classes and namespace.

If you actually try to connect to an MsSQL server we don’t know what target platform you currently target. Certain classes are only available on certain platforms. Apart from that it highly depends on what scripting backend you use (PlayerSettings) and what .NET version (also PlayerSettings).

Next point is depending on the server you want to reach there are in most cases multiple ways to do the same thing. Since we have absolutely no idea what you actually did in your code we can’t help you here.

Finally when you actually develop a game that should run on a user’s device, you never want to directly connect to an SQL server. Since the credentials for the server need to be shipped with your game, a hacker can extract those and can do whatever he wants to your database. You usually communicate through any kind of serverside interface like a php script, JavaServerPages, ASP.NET, NodeJS, etc …

Again totally unclear what you actually did or what you wanted to do. A stacktrace is pretty useless without the code that belongs to the stacktrace.