Author Topic: Switching profiles issue  (Read 6317 times)

Hollywood_315

  • Guest
Switching profiles issue
« on: August 18, 2017, 02:17:20 AM »
I'm sure I'm missing something basic here so appreciate guidance. Working on a plugin I have a simple profile that goes with it. All is well when I use only this profile, and all plugin functions work nicely as advertised. However, VA doesn't like it when I switch to another profile (which doesn't use the plugin btw) and then back. When I do this I get messages
UNABLE TO INVOKE PLUGIN. PLUGIN NOT VALID FOR THIS VERSION OF VOICEATTACK.

What am I missing? Is there some kind of state management I need to implement to prevent this?
Many thanks

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Switching profiles issue
« Reply #1 on: August 18, 2017, 02:32:18 AM »
That message tends to show up when a plugin crashes.

Do you have a command that will run when you load the first profile to set up your plugin, that would make your plugin break?

Plugins shouldn't be affected by profile switching itself, as long as you're not relying on profile-scoped VoiceAttack variables, as they would be discarded.

Hollywood_315

  • Guest
Re: Switching profiles issue
« Reply #2 on: August 21, 2017, 02:01:17 AM »
It's a bit puzzling. The profile is very basic and doesn't pass any variables, only context values. Even when I use a fully stripped-down profile the issue still remains. So apparently it is a feature of the plugin itself somehow. It doesn't crash on switching but only as soon as the plugin is invoked i.e. Invoke1 is called after profile switch. Do you have examples of what such profile-scoped VoiceAttack variables could be?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4782
  • RTFM
Re: Switching profiles issue
« Reply #3 on: August 21, 2017, 02:38:53 AM »
Profile-scoped variables are declared with a ">" prefix, meaning they're cleared when switching profiles.
See the "Advanced Variable Control (Scope)" in VoiceAttackHelp.pdf for more information on variable scopes.

You could try wrapping the contents of "VA_Invoke1" in a try/catch block and outputting any exceptions to the log or a messagebox.

What is your plugin supposed to do? Can you post the source code?

Hollywood_315

  • Guest
Re: Switching profiles issue
« Reply #4 on: August 22, 2017, 01:43:20 PM »
I tried the try/catch thing and some other stuff but to no avail. The plugin generates the error message even before it reaches the actual Invoke1 call, so I get no exception readout in the log. While looking for angles to debug I also noticed that the plugin generates the same errors if I change the guid in VA_Id(). The plugin initializes but as soon as Invoke1 is called there's a crash, even without any profile switching. When I put back the original guid value the problem is gone again. Which seems funny since I thought the value didn't matter as long as it is unique and in the right format (I use Registry format with VS generator tool). Investigations, somewhat frustratingly, continue.

To check: The main functions VA_Id() etc. I put in public static class 'Plugin'.  There are however callouts to other (static) classes  in the same namespace. I'm assuming that should not be any concern, but just to confirm. Thanks a lot.
« Last Edit: August 22, 2017, 01:51:02 PM by Hollywood_315 »

Hollywood_315

  • Guest
Re: Switching profiles issue
« Reply #5 on: February 12, 2019, 01:16:00 PM »