System.PlatformNotSupportedException

A friend and I are working on some mysql connection via a server application in unity. We have everything working in the Editor, no sweat, but when we built the game into a PC/Mac/Linux Standalone build (2018…3.12f1), when we run a MySQl command, we get the following error.

Is there a way to get this to work? We’re using the most recent mysql connector, and as I mentioned everything is working perfect in editor.

5231324--521795--unknown.png

The source for MySql.Data.MySqlConfiguration doesn’t have a constructor, so that exception is being thrown from the base class: System.Configuration.ConfigurationSection.

Getting a PlatformNotSupported exception from there suggests you are targeting a version of .net not supported by Unity runtime. Is your code compiled into a managed DLL and referenced from your project? Or just part of a script in your project?

What version of .net are you targeting? You should try to target .net standard if you’re not already.

I’m sorry to ask such a simple question, but how do I add a constructor? Why would it work in editor mode and not in the build? Can you guide me to where I would be able to do this?

It is a DLL from the mysql connector package. It has been added to assets and all of the code works dandy in the editor.

And I am using scripting runtime 4.x, but it shows the API compatibility level is .NET Standard 2.0. Is that what you mean?

EDIT: Alright, so @eisenpony got me thinking it was just the .net choice of API, and sure enough switching it to 4.x fixed my issue. I was using a newer MySQL connector. When I switched, I had to fix a couple lines of code in another library that I imported, but everything has been resolved. Thanks!

1 Like

Glad that worked for you. However, be aware that choosing an API level of 4.x will likely tie you to a Windows environment.

I investigated the MySQL connection libraries and found they target .NET 4.0 and don’t easily retarget to .NET Standard, so maybe there is no way around this problem besides what you’ve already done.