Dalamud
Dalamud copied to clipboard
Synchronously loading plugins cannot load dependencies properly
Plugins that load synchronously that use dependencies provided by Dalamud (such as SharpDX) will fail to load if they utilize these dependencies in their constructor.
Repro: https://github.com/lmcintyre/Dalamud1158
When the above plugin is built and loads at some time after startup, it executes properly:
2023-03-14 13:09:09.079 -04:00 [INF] [LOCALPLUGIN] Loading Dalamud1158.dll
2023-03-14 13:09:09.240 -04:00 [DBG] [Dalamud1158] Device: 1EC8DDD1380 Context: 1EC8DDDC2E8
2023-03-14 13:09:09.240 -04:00 [INF] [LOCALPLUGIN] Finished loading Dalamud1158.dll
However, if the plugin is allowed to load synchronously on startup, the following error occurs:
2023-03-14 13:09:33.943 -04:00 [ERR] [LOCALPLUGIN] Error while loading Dalamud1158
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.IO.FileNotFoundException: Could not load file or assembly 'SharpDX.Direct3D11, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1'. The system cannot find the file specified.
File name: 'SharpDX.Direct3D11, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1'
at Dalamud1158.Dalamud1158..ctor(DalamudPluginInterface pluginInterface)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.ConstructorInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
at System.Reflection.ConstructorInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
at System.Reflection.RuntimeConstructorInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Dalamud.IoC.Internal.ServiceContainer.CreateAsync(Type objectType, Object[] scopedObjects) in C:\goatsoft\companysecrets\dalamud\IoC\Internal\ServiceContainer.cs:line 104
at Dalamud.Plugin.Internal.Types.LocalPlugin.LoadAsync(PluginLoadReason reason, Boolean reloading) in C:\goatsoft\companysecrets\dalamud\Plugin\Internal\Types\LocalPlugin.cs:line 422
at Dalamud.Plugin.Internal.PluginManager.LoadPluginAsync(FileInfo dllFile, LocalPluginManifest manifest, PluginLoadReason reason, Boolean isDev, Boolean isBoot, Boolean doNotLoad) in C:\goatsoft\companysecrets\dalamud\Plugin\Internal\PluginManager.cs:line 879
2023-03-14 13:09:33.964 -04:00 [INF] [PLUGINM] Dev plugin failed to load, adding anyways: Dalamud1158.dll
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.IO.FileNotFoundException: Could not load file or assembly 'SharpDX.Direct3D11, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1'. The system cannot find the file specified.
File name: 'SharpDX.Direct3D11, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b4dcf0f35e5521f1'
at Dalamud1158.Dalamud1158..ctor(DalamudPluginInterface pluginInterface)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.ConstructorInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
at System.Reflection.ConstructorInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
at System.Reflection.RuntimeConstructorInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Dalamud.IoC.Internal.ServiceContainer.CreateAsync(Type objectType, Object[] scopedObjects) in C:\goatsoft\companysecrets\dalamud\IoC\Internal\ServiceContainer.cs:line 104
at Dalamud.Plugin.Internal.Types.LocalPlugin.LoadAsync(PluginLoadReason reason, Boolean reloading) in C:\goatsoft\companysecrets\dalamud\Plugin\Internal\Types\LocalPlugin.cs:line 422
at Dalamud.Plugin.Internal.PluginManager.LoadPluginAsync(FileInfo dllFile, LocalPluginManifest manifest, PluginLoadReason reason, Boolean isDev, Boolean isBoot, Boolean doNotLoad) in C:\goatsoft\companysecrets\dalamud\Plugin\Internal\PluginManager.cs:line 879
Note that this error occuring during a sync plugin load seems to prevent any other plugins from utilizing the library.