- Home /
Referencing Mono Framework assemblies
So I'm trying to use MEF (Managed Extensibility Framework) in the bleeding edge Mono of Unity 2017, but I'm unsure how to properly do it. Obviously I can't add the reference in the Visual Studio project since that's not only blocked but would get overridden everytime Unity regenerates the project anyway. The only thing i found in the forums is "copy the assembly into your asset folder". Is that really the way to do this? I mean, is there no place in the editor where I can tell Unity how to generate the project, to add a reference and copy the assembly in question to the build output later? Do I have to have that stuff in the asset folder? And if so.. it's a bit tricky to find the right one.
Do I use the one in Unity\Editor\Data\MonoBleedingEdge\lib\mono\4.5 or in C:\Program Files\Unity\Editor\Data\MonoBleedingEdge\lib\mono\4.5-api and so on.
I thought I had been able to add a reference to mono framework stuff in the past but I can't remember how. I THOUGHT there was some window in the editor where I could specify that.
Any help on this would be appreciated. If the best solution really IS copying the dll to the asset folder than I'd like to see this optimized in the future. I understand why I can't simply do it in my IDE as usual, but there should be a UI in the editor to do this. I shouldn't have to go assembly hunting.
Answer by Bunny83 · Oct 03, 2017 at 08:53 PM
No, the only way is to actually include the assemblies in your project. Keep in mind that a Unity game does not rely on the Mono or .NET framework on the users computer like normal .NET / Mono applications. The Unity engine is actually written in C++. It just uses Mono as scripting environment. By default it only includes the core assemblies which are necessary.
If you need additional functionality you have to include those assemblies in your project. It actually doesn't matter if it's an assembly from the Mono framework or one of your own assemblies.
Finally the reason why the Unity VS Tools actively prevent you from editing the project settings is that Unity actually doesn't care about the ".csproj" file at all. It just creates those automatically so you can open the project in VS / MonoDevelop. Unity actually builds the project assemblies "manually". It automatically references all assemblies which are in the project when compiling the scripts in the project.
Answer by KeldorKatarn · Oct 03, 2017 at 08:59 PM
Fair enough. I know WHY I can't add it and I know it doesn't rely on an installation. I just wondered if there was an easier way to include an assembly. The mono runtime assemblies of the mono version that unity uses are included in the installation, so it would be easier if I could just go in the editor to some play and select the mono assemblies I need in my project and Unity would add the automatically without me having to go and search for the DLL to copy it. But thanks for the reply. I just wanted to make sure I'm not missing an easier and better way to do things.