Using a .dll in Unity C#

I am currently working with Unity3D, and need to import a .dll file compiled in VS2008, using .net 2.0. It works perfectly well on the PC version and it works just like I want it to, but it somehow breaks my iOS build. I’m not even using the .dll on mobile devices, and the code linking to the dll (DllImport) is compiled only in the PC build.

I’m getting the following error when building for iOS :

ArgumentException: The Assembly Microsoft.VisualC is referenced by mydll. But the dll is not allowed to be included or could not be found.

I’ve changed to api compatibility level (in the player settings for all platforms in unity) to .net 2.0, and built my dll targetting the 2.0 .net level as well.

Why is the dll even in my build ? What are the correct steps to import a .dll, maybe I’ve missed something crucial ?

QUICK EDIT : The .net api compatibility wasn’t set correctly in the end for iphone, but I’m still getting some error :

Error building Player: NullReferenceException: Object reference not set to an instance of an object

I think it’s during the AOT cross compile phase of the player creation. Maybe someone knows how to deal with this ?

Also, maybe it was unclear in my question, but my DLL uses managed code to be able to access .net functions.

UPDATE : Been working on this a bit on my end, now I’m wondering if there is a way to simply exclude this .dll from my iOS build ? (apart from doing it manually everytime I want to build). I can’t seem to find out a way to do this. I’ve tried stripping, but it doesn’t work well with other parts of my application (breaks some things), and now I’m a bit lost. I can manually remove and add it as a workaround but would really like a cleaner solution !

Do you have the Windows .dll in an x86 folder, or x86_64 folder? This will tell Unity that it is a Windows specific .dll.
Special Folder Names