I currently working on 2 Unity projects. For these two I'm writing a library to easily get login data from a server, dialog text from xml, etc. I build the dll right out of Visual Studio, so it's referencing microsofts system.dll, system.data.dll etc.
I have to be sure that the library works on Windows and Mac. Won't the microsoft dll's cause problems on Mac?
Does it make sense te remove all references to the microsoft .NET framework in my visual studio project and in stead replace them with the Mono.NET dll's? Or am I talking crazy here?
Answer by Lucas Meijer 1
Feb 22, 2010 at 10:28 AM
Both can work fine. What you should make sure is that the functionality you use from the system libraries, is actually supported in the version of Mono that is shipped with Unity.
Most stuff is supported, but there are some gaps in newer functionality (stuff like Linq, ParallelFX, etc).
The safest would be to just reference Mono's libraries (you can find them in the unity editor's install folder), as you would notice any types not being available.
Please note that "which version" you referenced, does not get remembered. When Unity or Visual Studio makes an assembly out of your sourcecode, that just says "Use System.dll". It does not specify a specific vendor, nor does it embed System.dll.
I tried referencing the Mono .NET assemblies (Unity 3.0\Editor\Data\Mono\lib\mono\unity) from within my VS2010 project, but VS ignores the location. That is, it accepts the dll's as valid within the 'Add Reference' dialog, but if I look at the properties on each reference they still point to the standard .NET location (C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll). Any ideas how to actually compile against the Unity Mono assemblies?
Answer by Cawas
Feb 19, 2010 at 06:27 PM
I don't really know or have the experience, but I bet Microsoft DLL can cause problems on the Mac. No crazy talk there - if you can use Mono.NET rather than MS.NET I highly suggest you to do so. It is made for that purpose.
Mono.NET is now linked to someone's personal site.
Answer by Frederik
Feb 22, 2010 at 09:28 AM
Maybe anyone else encountered this problem too?
Answer by Shawn
Feb 23, 2010 at 12:45 AM
I have done some compiling of DLLs for use with Unity iPhone and the biggest problem I have found is making sure you are compiling against the correct version of mono and not attempting to use features which are not in the Unity version of mono.
I have compiled numerous DLLs using .NET 2.0 in VS and they work just fine on the Mac and iPhone; but there are certain features that .NET 2.0 supports which if you use will cause errors on the Unity side.
Answer by Ashkan_gc
Feb 23, 2010 at 05:51 AM
as lucas said you don't need to reference mono DLLs to make your library compatible with unity but it will help in visual studio because you can see what is available in mono or not. if you use vs 2008, choose .NET 2.0 as the target platform because newer features and even some of 2.0's features are not available in unity's mono version. there is an analyzer tool called MOMA that you can use to check if there is any errors available. it will tell you about methods that you used that they are not available in mono.
when you compile an assembly, the compiler will create CIL code from your code and store them in a PE (EXE) file. it also stores metadata and references names and ... there is no difference between compiling with mono or Microsoft's compilers or using Microsoft or mono libraries. the runtime that you use (mono/MS .NET) should have those libraries and methods that use use or should be able to execute those CIL instructions. most of the times the problem is about platform dipendent libraries that mono should implement for each platform. so you just need to make sure mono has the libraries that you use and also see if it supports those methods that you use or not.
Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.
The best place to ask and answer questions about development with Unity.
To help users navigate the site we have posted a user guide.
If you are a new user, check out our FAQ for more information.
If you are a moderator, see our Moderator Guidelines page.
We are making improvements to UA, see the list of changes.
For troubleshooting common problems with Unity 5.x Editor (including Win 10).
Answers and Comments
No one has followed this question yet.
Does a plugin work independent of MONO framework?
Exclude some dlls to load when build is not PC?
Having issues using my .dlls
mono: failed to load dll
How do you integrate the EPPlus library into Unity?