Loading asset bundles: System.ArgumentNullException: Value cannot be null. (Parameter 'meth')
What happened?
Hello! I'm trying to import an asset bundle into an IL2CPP game (built with Unity 2020.3.18 targeting Windows). Well I'm trying via RessourceStream (*note that the exact same error occurs with AssetBundle.LoadFromFile), and I have the following error.
namespace JarodMod;
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)]
public class Plugin : BasePlugin
{
internal static new ManualLogSource Log;
public override void Load()
{
// Plugin startup logic
Log = base.Log;
Log.LogInfo($"Plugin {MyPluginInfo.PLUGIN_GUID} is loaded UPDATED!");
Harmony.CreateAndPatchAll(typeof(Plugin));
// AssetBundle
using var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("JarodMod.jarodbundle");
var assetBundle = AssetBundle.LoadFromMemory(stream!.ReadBytes());
Log.LogInfo("AssetBundle loaded successfully.");
}
}
I've built the Asset Bundle using the same version as the game (mentioned above). I hope you'll be able to help me with this issue. Thanks!
BepInEx Distribution
Bleeding Edge from BepisBuilds
Log outputs
[Error : BepInEx] Error loading [Jarod 1.0.0]: System.ArgumentNullException: Value cannot be null. (Parameter 'meth')
at System.Reflection.Emit.DynamicILGenerator.Emit(OpCode opcode, MethodInfo meth)
at Il2CppInterop.Runtime.InteropTypes.Il2CppObjectBase.InitializerStore`1.Create() in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/InteropTypes/Il2CppObjectBase.cs:line 124
at Il2CppInterop.Runtime.InteropTypes.Il2CppObjectBase.InitializerStore`1.get_Initializer() in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/InteropTypes/Il2CppObjectBase.cs:line 146
at Il2CppInterop.Runtime.Runtime.Il2CppObjectPool.Get[T](IntPtr ptr) in /home/runner/work/Il2CppInterop/Il2CppInterop/Il2CppInterop.Runtime/Runtime/Il2CppObjectPool.cs:line 40
at UnityEngine.AssetBundle.LoadFromMemory_Internal(Il2CppStructArray`1 binary, UInt32 crc)
at UnityEngine.AssetBundle.LoadFromMemory(Il2CppStructArray`1 binary)
at JarodMod.Plugin.Load() in E:\SteamLibrary\steamapps\common\Road 96\BepInEx\plugins\JarodMod\Plugin.cs:line 28
at BepInEx.Unity.IL2CPP.IL2CPPChainloader.LoadPlugin(PluginInfo pluginInfo, Assembly pluginAssembly) in /home/runner/work/BepInEx/BepInEx/Runtimes/Unity/BepInEx.Unity.IL2CPP/IL2CPPChainloader.cs:line 134
at BepInEx.Bootstrap.BaseChainloader`1.LoadPlugins(IList`1 plugins) in /home/runner/work/BepInEx/BepInEx/BepInEx.Core/Bootstrap/BaseChainloader.cs:line 411
Environment
- OS: Windows 10 22H2
- BepInEx: 6.0.0-be.697 (build commit `53625800b86f6c68751445248260edf0b27a71c2`)
- Game: Road 96
Btw, tell me if you need more info, or if I can speed up the process in any way :D
Sorry, your issue is outside my area of expertise; I was just labeling GitHub issues. I primarily focus on the generator portion of the codebase.
Was there ever a solution to this?
Was there ever a solution to this?
In order to get Asset Bundles when you get this error, you can use this lib https://github.com/yukieiji/UniverseLib
The issue should be resolved. I merged a pr 3 months ago which was supposed to fix this.
The issue should be resolved. I merged a pr 3 months ago which was supposed to fix this.
I haven't really had the occasion to try it since. Let's say it works
The issue should be resolved. I merged a pr 3 months ago which was supposed to fix this.
I updated to latest BIE Bleeding Edge, and still got the issue D:
I tried loading my Asset Bundle like that this time:
var dogBundle = AssetBundle.LoadFromFile(Path.Combine(Application.streamingAssetsPath, "dog"));
if (dogBundle == null)
{
Debug.Log("Failed to load AssetBundle!");
return;
}
var dogMat = (Material)dogBundle.Load<Material>("dog_mat");
Sorry for not testing before D:
The issue should be resolved. I merged a pr 3 months ago which was supposed to fix this.
I updated to latest BIE Bleeding Edge, and still got the issue D:
Are you sure the BIE Bleeding Edge uses the latest Interop commit?
No, but I'm not sure how to switch to latest Interop.
I think the current version of MelonLoader uses an Interop build with the commit that fixed your issue.
Alternatively, you can build Bepinex from source and update the version before building.
Can you not just update BepInEx to actually reflect these changes? It's kinda annoying having to build BepInEx and not being able to properly publish the plugin dll.
Can you not just update BepInEx to actually reflect these changes?
I do not have the permissions required for this action.
Can you not just update BepInEx to actually reflect these changes?
I do not have the permissions required for this action.
Guess I'll have to wait then until it's fixed for BepInEx, that is the only part that I am stuck on atm and I cannot use MelonLoader as I cannot use that DLL in Unity for custom component scripts.