Can't build project importing System.Data

Hello everyone!

Well my problem is this: I usually code in .net at work using C# and develop some apps that use database connection using ado.net. I’m currently using a windows-build making a database connection using the same approach here in unity and I’ve made it work so far (I’ve placed the 2 ddls I need (system.data and system.enterpriseservices) in the asset folder). Whenever I hit the play button everything works correctly… BUT THE REAL PROBLEM STARTS NOW:

Whenever I build the project I get this error messages:

ArgumentException: The Assembly
System.Configuration is referenced by
System.Data. But the dll is not
allowed to be included or could not be
found.

Error building Player: Extracting
referenced dlls failed.

I tried restarting due to possively locked dlls or whatever but it didn’t work =(. Also, I tried putting in the asset folder the system.configuration dll and it didn’t work either =(.
Sooo… yeah, I googled and searched here for a while and supposedly there’s a workaround for this: edit-> project settings → player → change api compatibility level to .net 2.0

Which IS actually a workaround in terms of making the project BUILD. I mean: whenever I do this I can build the project successfully (after I restart unity of course), BUT the connection with the database doesn’t work: it gives me this error message whenever it tries to open the connection:

SecurityException: Couldn’t
impersonate token.

I am completely baffled at why there’s any windows impersonation happening here. Has anyone successfully made a unity build using the System.Data dll? Should I use the mono’s system.data or the microsoft.net system.data? Has anyone make it work using linq? I don’t really know linq but I could learn it if no one can make this work.

Oh, and I don’t wanna use a web script to handle my database using a WWW class, because this is just a presentation project and I don’t really care if I’m gonna get hacked cause it’ll be on an intranet.

Thanks a ton everyone!!

What kind of build do you want to create? A webbuild doesn’t allow any native code dlls to be included. There is absolutely no way around that. The UnityWebPlayer runs in a security sandbox.

If you build a standalone windows player, there’s no reason why it shouldn’t work. I never used ADO.NET, but i’ve successfully connected to my local mysql server (of course with a mysql connector). I can’t tell you what you need to include or how to setup it correctly.

It tells you that “System.Configuration is referenced by System.Data”, so are you sure you included all dependencies of the System.Data dll you’re using?