I’m running into issues integrating the library called EPPlus into my Unity project. I rely on this library to create .xlsx files that organize a bunch of data gathered from a play session once the game has finished running.
Initially, when I added the .dll to my project, I received an error that looked like this:
Internal compiler error. See the console log for more information. output was:
Unhandled Exception: System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
I did some searching, and found that going to the player settings and setting the configuration option “API compatibility level” to ‘.NET 2.0’ instead of ‘.NET 2.0 subset’ fixed this issue. This was great and all, and I proceeded to use the library with great joy. It spit out .xlsx files exactly how I wanted it to, and everything was going fine. Except there is one catch: this only works in the editor.
As soon as I started to compile a standalone build, I ran into more issues. The 2 error messages I received are as follows:
ArgumentException: The Assembly PresentationCore is referenced by EPPlus. But the dll is not allowed to be included or could not be found.
Error building Player: Extracting referenced dlls failed.
This is where I am stumped. I did research on what is allowed/not allowed in the Unity engine when it comes importing external code, but everything seems like it should work. Unfortunately, it does not. I was wondering if anyone here has any insight as to why this library would not function well with Unity.
Some more information about the issue:
- I have a free version of Unity, and the current version is 4.5.2
- EPPlus.dll is a managed library and it does not use native code (AFAIK), so Unity Pro and [DLLImport] functionality is not required.
- EPPlus.dll is compatible with .Net Framework 3.5, which I believe is the last version that MonoDevelop supports.
- The EPPlus.dll currently resides in the Assets/Libraries path in my project, but I have also tried Assets/Plugins to no effect. In fact, it doesn’t really matter where I put it as long as it is in the Assets folder and not in a folder named “Editor”.