Hi!
I am getting the following error when unloading my plugin:
I have attached the plugin as it is easier than explaining here how it uses the timer library.Code:[Oxide] 18:54 [Error] Failed to call hook 'ConsoleUnload' on plugin 'RustCore v1.0.0' (NullReferenceException: Object reference not set to an instance of an object) [Oxide] 18:54 [Debug] at Oxide.Core.Libraries.Timer+TimerInstance.Remove () [0x00000] in <filename unknown>:0 at Oxide.Core.Libraries.Timer+TimerInstance.Destroy () [0x00000] in <filename unknown>:0 at Oxide.Core.Libraries.Timer+TimerInstance.OnRemovedFromManager (Oxide.Core.Plugins.Plugin sender, Oxide.Core.Plugins.PluginManager manager) [0x00000] in <filename unknown>:0 at Oxide.Core.Event`2[T1,T2].Invoke (.T1 arg0, .T2 arg1) [0x00000] in <filename unknown>:0 at Oxide.Core.Plugins.Plugin.HandleRemovedFromManager (Oxide.Core.Plugins.PluginManager manager) [0x00000] in <filename unknown>:0 at Oxide.Plugins.CSharpPlugin.HandleRemovedFromManager (Oxide.Core.Plugins.PluginManager manager) [0x00000] in <filename unknown>:0 at Oxide.Core.Plugins.PluginManager.RemovePlugin (Oxide.Core.Plugins.Plugin plugin) [0x00000] in <filename unknown>:0 at Oxide.Core.OxideMod.UnloadPlugin (System.String name) [0x00000] in <filename unknown>:0 at Oxide.Game.Rust.RustCore.ConsoleUnload (.Arg arg) [0x00000] in <filename unknown>:0 at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (object,object[],System.Exception&) at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0
I am using the latest version of oxide, I noticed there were a lot of changes to the timer library. I believe this is an issue with the timer library itself? But I could be wrong and it might be with the way I have created timers to be destroyed later. I have commented out anything called in the unload method within my plugin just out of curiosity but that has made no difference.
All help is appreciated!
Solved Oxide timer NRE on unload (C#)
Discussion in 'Rust Development' started by JoeSheep, Jun 3, 2016.
-
Attached Files:
Last edited by a moderator: Jun 3, 2016 -
-
Wulf Community Admin
Update Oxide and it should be fixed.
-
@Wulf Awesome work, though I am afraid I now get this NRE, again with unloading:
Code:[Oxide] 19:22 [Error] Exception while calling NextTick callback (NullReferenceException: Object reference not set to an instance of an object) [Oxide] 19:22 [Debug] at Oxide.Core.Libraries.Timer+TimerInstance.Remove () [0x00000] in <filename unknown>:0 at Oxide.Core.Libraries.Timer+TimerInstance.Destroy () [0x00000] in <filename unknown>:0 at Oxide.Core.Libraries.Timer+TimerInstance.OnRemovedFromManager (Oxide.Core.Plugins.Plugin sender, Oxide.Core.Plugins.PluginManager manager) [0x00000] in <filename unknown>:0 at Oxide.Core.Event`2[T1,T2].Invoke (.T1 arg0, .T2 arg1) [0x00000] in <filename unknown>:0 at Oxide.Core.Plugins.Plugin.HandleRemovedFromManager (Oxide.Core.Plugins.PluginManager manager) [0x00000] in <filename unknown>:0 at Oxide.Plugins.CSharpPlugin.HandleRemovedFromManager (Oxide.Core.Plugins.PluginManager manager) [0x00000] in <filename unknown>:0 at Oxide.Core.Plugins.PluginManager.RemovePlugin (Oxide.Core.Plugins.Plugin plugin) [0x00000] in <filename unknown>:0 at Oxide.Core.OxideMod.UnloadPlugin (System.String name) [0x00000] in <filename unknown>:0 at Oxide.Plugins.CSharpPluginLoader.<CompileAssembly>m__2 (Oxide.Plugins.Compilation compilation) [0x00000] in <filename unknown>:0 at Oxide.Plugins.Compilation.<Completed>m__2 () [0x00000] in <filename unknown>:0 at Oxide.Core.OxideMod.OnFrame (Single delta) [0x00000] in <filename unknown>:0
-
Wulf Community Admin
-
2.0.1998 -
Is this happening because in my plugin I have the variable:
Code:var timerInstance = new Oxide.Core.Libraries.Timer.TimerInstance(null, 1000, 1000, null, this);
Last edited by a moderator: Jun 3, 2016 -
Wulf Community Admin
-
-
Wulf Community Admin
-
Don't you tsk tsk at me!
I shall do my homework in that case! -
Wulf Community Admin
-
Holy crap though why on earth did I ever go about doing it the way I have... -
Having a slight issue with destroying the timer now.
In the plugin class scope I have:
Code:Timer GlobalTimer;
Code:var GlobalTimer = timer.Once(msgShowDuration, () => destroyGlobalGUI());
Code:if(GlobalTimer != null && !GlobalTimer.Destroyed) { Puts("Timer not destroyed"); GlobalTimer.Destroy(); }
-
Wulf Community Admin
-
What you're looking for is GlobalTimer = timer.Once(msgShowDuration, () => destroyGlobalGUI());. -