Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loading the plugin with css_plugins load after having unloaded it will throw a looping error "System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation." #99

Closed
DragonHeart000 opened this issue Nov 18, 2024 · 4 comments

Comments

@DragonHeart000
Copy link

Summary: Loading the plugin with css_plugins load after having unloaded it will throw a looping error "System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation."

Version: 0.3.1

Call stack:

08:41:35 [EROR] (cssharp:Core) Error invoking callback
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.Collections.Generic.KeyNotFoundException: The given key '0' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at SharpTimer.SharpTimer.<Load>b__673_1(CCheckTransmitInfoList infoList) in E:\noobclub\poor-sharptimer\src\SharpTimer.cs:line 94
   at InvokeStub_CheckTransmit.Invoke(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at CounterStrikeSharp.API.Core.BasePlugin.<>c__DisplayClass51_0`1.<RegisterListener>b__2(ScriptContext context) in /home/runner/work/CounterStrikeSharp/CounterStrikeSharp/managed/CounterStrikeSharp.API/Core/BasePlugin.cs:line 298
   at InvokeStub_Action`1.Invoke(Object, Span`1)
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at CounterStrikeSharp.API.Core.FunctionReference.<CreateWrappedCallback>b__18_0(fxScriptContext* context)

Repro rate: 5/5

Repro steps:

  1. Launch the server running the latest version of this plugin.
  2. Unload the plugin by running css_plugins unload plugins/SharpTimer/SharpTimer.dll.
  3. Load the plugin back up by running css_plugins load plugins/SharpTimer/SharpTimer.dll.
  4. Notice that the console will be spammed with the above call stack and the plugin will not work.

Note: Attempting to reload the plugin with css_plugins reload plugins/SharpTimer/SharpTimer.dll it will state "Could not reload plugin "plugins/SharpTimer/SharpTimer.dll""

Video: https://github.com/user-attachments/assets/05442c0b-eeb2-4404-acf4-725df0de9dec

@DragonHeart000
Copy link
Author

DragonHeart000 commented Nov 18, 2024

Is there a different or more files that should be reloaded other than SharpTimer.dll? There were a few I tried but none with good results. SharpTimer.dll was at least able to disable the plugin but not reenable it. Alternatively, is there a cvar that enables/disables this plugin? Or is this just not possible with the plugin currently?

@exkludera
Copy link
Contributor

Is there a different or more files that should be reloaded other than SharpTimer.dll? There were a few I tried but none with good results. SharpTimer.dll was at least able to disable the plugin but not reenable it. Alternatively, is there a cvar that enables/disables this plugin? Or is this just not possible with the plugin currently?

it's not possible atm, restarting the server is the only solution. it can probably be fixed but I don't think it's a priority right now, also idk why anyone would need to disable & enable the plugin 🫨

@DragonHeart000
Copy link
Author

I'm trying to find a way to disable and enable the plugin as I am using this server for multiple game modes. Don't want to have to have a timer when I switch the game mode to retakes for example. I was attempting to have different cfgs that would run on a per map basis so when the map changes to another game mode it would enable and disable the proper plugins for it and change any other settings needed.

Appreciate the confirmation on it not being possible currently at least so I don't keep trying to find a way to make it work this way. If it's not a priority for the dev team currently I may look into the issue myself.

@M-archand
Copy link
Collaborator

Not currently a priority, as gamedata would make this difficult to fix. Use ds_workshop_changelevel as a workaround to reload the plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants