The project was compiling fine yesterday, and I haven’t made that many changes today. I’ve tried reinstalling Unity and deleting the /Temp folder, as well as changing the Api Compatibility Level from .NET 2.0 Subset to .NET 2.0, but nothing seems to work. Does anyone have an idea? I’m going nuts and would appreciate the help.
Hmm… this exception usually means that a DLL you’re trying to access either isn’t managed or is corrupt. Is there anything else that’s been compiled in your project or maybe a 3rd party assembly that’s compiled for a target (like x64 instead of Any CPU)?
Thanks for the reply. It just got weirder. I created a new, empty project. It compiled. Then I created blank C# and JS scripts (leaving the default, empty functions), and hit build. I got the exact same error as above.
I looked in Temp/StagingArea/Data/Managed, and both Assembly-CSharp.dll and Assembly-UnityScript.dll are Zero bytes(!). The same files in Library/ScriptAssemblies and 3KB and 2KB respectively. What is going on? Any ideas?
I had this same problem in Unity 5.6, Google Cardboard 1.5, until I moved my project to the main drive of my mac. It failed with this error when building on a second partition of the drive.
Wanted to report that I’m using Unity 5.6.1f1 on Windows 10, trying to build a Google Daydream app and I had to move my project onto my main drive. Trying to build from a secondary drive was giving me a “!IsDirectoryCreated(kManagedDllsFolder)” error with an IO exception related to the DLL.
I finally fixed this. May not work for everyone.
I deleted Everything, without of (/keeping) Assets and Packages folder. And after opening again, the problem solved.
I think there was a problem with the library folder. Something might had corrupted.
Note that I also installed new version of Unity. But I think it has not effected my project so much.
Again, might not work for all but it may help you.
I had this error too, I had my project in an SSD so I copied it to the main drive and now the project builds without errors… The issue is now in Xcode saying ‘Linker command failed with exit code 1 (use -v to see invocation)’
Im still having issues with this and I have deleted my libary folder twice.
Got anymore Ideas on what it could be?
System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid.
at Mono.Cecil.PE.ImageReader.ReadImage()
at Mono.Cecil.PE.ImageReader.ReadImage(Disposable1 stream, String file_name) at Mono.Cecil.ModuleDefinition.ReadModule(Disposable1 stream, String fileName, ReaderParameters parameters)
at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
at ApiUpdater.MovedFromOptimizer.Program.CollectMovedFromTypeNamesFromAssembly(String assemblyPath, StreamWriter outputFile, IAPIUpdaterListener logger)
at ApiUpdater.MovedFromOptimizer.Program.RealMain(String[ ] args)
at ApiUpdater.MovedFromOptimizer.Program.Main(String[ ] args)
Error building Player because scripts had compiler errors
Build completed with a result of ‘Failed’ in 5 seconds (5255 ms)
2 errors
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)
Im going to keep trying but so far it hasnt worked, Had an issue earlier and it seemed to resolve that.