How to use Mono dllname.dll.config with Unity?

What is working

I have a Mono project (independent of Unity) using Cloo. Cloo uses native OpenCL.dll. In order to have it working in other platforms, I added the following file to my project:
Cloo.dll.config, with contents:

<?xml version="1.0" encoding="utf-8"?>
  <dllmap os="linux" dll="OpenCL.dll" target=""/>
  <dllmap os="osx" dll="OpenCL.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>

That remaps the dll to the appropriate file both on Linux and on MacOSX (10.7).

What is the problem

Now I need to use Cloo.dll in a Unity project. I tried to include the Cloo.dll.config in many ways, but cannot have it working in any proper way.
The project works perfectly on windows, both in “Play” mode and in a UnityEditor script.


That brings me down to my questions:

  1. Do I need the UnityPro Plugin feature for this to work with Unity?
  2. How can I have that remapping working on MacOS Standalone player?
  3. Is there anything different I need to do to have it working on UnityEditor in MacOS?

As a note, I do NOT include OpenCL.dll in the project, nor I cannot do so, since they are available through the runtime installed in the system, and many times dependant on grphics card model and driver version.

I was trying this myself recently and wasn’t getting anywhere, then I was pointed towards your question here and you actually gave me enough information to get me thinking on the right lines and get it started.

The solution I’m using is documented at - let me know if there’re any problems.