Could not load file or assembly 'Facebook.Unity.Gameroom' Exception occurs on IL2CPP build.
We are getting the following exception while running our game on Facebook Gameroom and calling FB.Init() function.
We are using Unity 2019.1.8f1 and IL2CPP build. If we use mono build this works fine but we want to use IL2cpp only.
FileNotFoundException: Could not load file or assembly 'Facebook.Unity.Gameroom' or one of its dependencies at System.AppDomain.Load (System.String assemblyString) [0x00000] in :0 at System.Reflection.Assembly.Load (System.String assemblyString) [0x00000] in :0 at Facebook.Unity.Gameroom.GameroomFacebookLoader.get_FBGameObject () [0x00000] in :0 at Facebook.Unity.FB+CompiledFacebookLoader.Start () [0x00000] in :0
We have verified that Facebook.Unity.Gameroom.dll is getting copied to Library/PlayerDataCache\Win\Data\Managed folder but this exception still occurs as soon as game calls FB.Init method.
Let us know if someone knows what causes this issue or any fixes for the same.
With IL2CPP, all of the managed code must be compiled ahead of time. I believe Facebook.Unity.Gameroom.dll is a managed assembly, is that correct? If so, IL2CPP should convert it to C++ code at build time. Do you know if this assembly is registered as a managed plugin for the project? See https://docs.unity3d.com/$$anonymous$$anual/UsingDLL.html for details.
Answer by Gwom · Aug 27, 2021 at 01:02 PM
I added this to the Assets\FacebookSDK\link.xml file and it stopped complaining about it - this is what my link file now looks like:
<linker>
<assembly fullname="Facebook.Unity.Android" ignoreIfMissing="1">
<type fullname="Facebook.Unity.Android.*" preserve="all"/>
</assembly>
<assembly fullname="Facebook.Unity.IOS" ignoreIfMissing="1">
<type fullname="Facebook.Unity.IOS.*" preserve="all"/>
</assembly>
<assembly fullname="Facebook.Unity.Canvas" ignoreIfMissing="1">
<type fullname="Facebook.Unity.Canvas.*" preserve="all"/>
</assembly>
<assembly fullname="Facebook.Unity.Gameroom" ignoreIfMissing="1">
<type fullname="Facebook.Unity.Gameroom.*" preserve="all"/>
</assembly>
</linker>
Your answer
Follow this Question
Related Questions
Build WebGL with v7.9.0 Facebook SDK error. 1 Answer
build with IL2CPP error unity 4.6.9 while making iOS build 1 Answer
Buliding Android Game | Exception - il2cpp.exe did not run properly 0 Answers
il2cpp+mysql error 2 Answers
When script debugging is selected, an error is generated in the il2cpp build 0 Answers