I would like to raise this topic again, because the team I working in has just got into similar problem.
I don't see actual solution in the above comments, and the latest post by the topic starter is unfortunately rather confusing to me -
Finally understood how make this work. I thought that this dlls i should place in folder with project, BUT all dlls must be placed in bin/win_64/ (couse im working on this platform) folder of EDITOR not project
To elaborate on the issue again:
We are using CryEngine 5.4, and working on a C# game plugin.
Recently we had a need to add another C# dll as a dependency (reference) to our plugin. That dll is a 3rd party utility library, not directly related to CryEngine.
When launching the game it crashes at startup, and following error may be found in the log:
Code: Select all
System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
at System.Reflection.Assembly.GetTypes () [0x00000] in C:\j\workspace\v\repos\mono\mcs\class\corlib\System.Reflection\Assembly.cs:402
at CryEngine.Engine.ScanAssembly (System.Reflection.Assembly assembly) [0x00006] in D:\jk\gamesdk_release\Code\CryManaged\CESharp\Core\Engine.cs:121
Moving ahead, I linked another random C# DLL to the project for a test, and it gives different error, similar to the one that topic starter had (noted in the first post):
Code: Select all
System.IO.FileNotFoundException: Could not load file or assembly '<Random Library Name>, Version=220.127.116.11, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: '<Random Library Name>, Version=18.104.22.168, Culture=neutral, PublicKeyToken=null'
at CryEngine.Projects.Game.Game.Initialize () [0x00019] in <filename unknown>:0
at CryEngine.Projects.Game.MyPlugin.Initialize () [0x00019] in <filename unknown>:0
The difference in errors may be related to how and when the contents of DLLs are used (whether we use a variable of some type, or simply put "using namespace" somewhere), but that's only my guess.
So, we did some research, and found that when game is launched, CryEngine copies C# plugins to the temporary folder, located at C:\Users\<Username>\AppData\Local\Temp\CE_ManagedBinaries.
We found, that if we manually copy the new dependencies there, then the game runs successfully, which hints that engine expects to find these dlls there, instead of the game's bin folder.
My question is this: what is the correct way to add dependencies to the C# plugins when working with Cry project, and what we may be missing or doing wrong (project configuration, or else)?
Almost forgot, I tried using a solution mentioned above, one with SetEnvironmentVariable("PATH"), but it did not work for me (or maybe I don't use it correctly...).