KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: DgnVoiceCommand.MenuCreate and VCMDERR_MENUEXIST
Topic Summary: Any way to eliminate the VCMDERR_MENUEXIST error when restarting a crashed program
Created On: 02/05/2012 10:22 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 DgnVoiceCommand.MenuCreate and VCMDERR_MENUEXIST   - Wade Hatler - 02/05/2012 10:22 PM  
 DgnVoiceCommand.MenuCreate and VCMDERR_MENUEXIST   - R. Wilke - 02/06/2012 06:29 PM  
 DgnVoiceCommand.MenuCreate and VCMDERR_MENUEXIST   - monkey8 - 02/08/2012 01:27 PM  
 DgnVoiceCommand.MenuCreate and VCMDERR_MENUEXIST   - R. Wilke - 02/08/2012 01:59 PM  
 DgnVoiceCommand.MenuCreate and VCMDERR_MENUEXIST   - monkey8 - 02/08/2012 02:30 PM  
 DgnVoiceCommand.MenuCreate and VCMDERR_MENUEXIST   - R. Wilke - 02/08/2012 02:46 PM  
 DgnVoiceCommand.MenuCreate and VCMDERR_MENUEXIST   - Wade Hatler - 02/10/2012 03:42 PM  
Keyword
 02/05/2012 10:22 PM
User is offline View Users Profile Print this message


Wade Hatler
New Member

Posts: 9
Joined: 07/04/2009

I wonder if anybody has run into this problem using the DragonTools API. I created a small simple test program that looks more or less like this:

    vCmd = new DgnVoiceCommand (); 

    vCmd.CommandRecognize += RecognizeMe;

    vCmd.Register("", DgnRegisterConstants.dgnregGlobalCM);

    myMenu = vCmd.MenuCreate("DragonTamer", "DragonTamer Menu", DgnLanguageConstants.dgnlangEnglish, "",  CREATEFLAGS.vcmdmc_CREATE_TEMP);

    myMenu.Add(1, "Test Me", "Testing 123", "Testing 123";

On program shut down, you Unegister the menu using:

    myMenu.Active = false;

    vCmd.UnRegister();

So far so good, and that's all pretty simple and straightforward.

 

The problem comes if I fail to UnRegister.  If the program crashes, or I terminate it early, or for any other reason I don't call the UnRegister command, then the next time I run the program, the MenuCreate command returns VCMDERR_MENUEXIST.  There doesn't seem to be any way to ensure that it gets released on abnormal program termination, and I also have searched the API high and low and can't find a way to check to see if the menu exists and simply get a handle to the same menu.

Does anybody know a good answer to this?  I imagine you KnowBrainer guys must've run into this making the product, so I'm hoping you have a Word from the Wise.

Thanks In Advance,



-------------------------
Wade Hatler
 02/06/2012 06:29 PM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 5245
Joined: 03/04/2007

If my assumption is correct, you are doing this in C#. Do you have any code like below in there, which is supposed to take care of it, and you don't even have to call unregister:

 

/// <summary>
/// Clean up any resources being used.
/// </summary>

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}



-------------------------

 02/08/2012 01:27 PM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 2432
Joined: 01/14/2008



-------------------------


www.pcbyvoice.com
www.pcbyvoice.co.uk

 02/08/2012 01:59 PM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 5245
Joined: 03/04/2007

I won't argue about tidying up and disposing of everything properly, however if you look at the C sharp sample coming with the SDK, none of this is actually done, except for the dispose function related to the form.

So this is where I copied the code snippet and pasted it here.

I also agree about this being neglected whenever such error messages show up in the log files.

Rüdiger

… Just adding to it. You can compile the sample referred to above and run it, close down the form and restart it no problem also.



-------------------------

 02/08/2012 02:30 PM
User is offline View Users Profile Print this message

Author Icon
monkey8
Top-Tier Member

Posts: 2432
Joined: 01/14/2008

Quote:
I won't argue about tidying up and disposing of everything properly, however if you look at the C sharp sample coming with the SDK, none of this is actually done, except for the dispose function related to the form.


I think you'll find it is now with the with the latest samples, and like I say you can avoid the error by simply setting the Active property of the menu to false, and by the sounds of it your method as well taken from the previous SDK samples.

Lindsay

-------------------------


www.pcbyvoice.com
www.pcbyvoice.co.uk

 02/08/2012 02:46 PM
User is offline View Users Profile Print this message

Author Icon
R. Wilke
Top-Tier Member

Posts: 5245
Joined: 03/04/2007

I am not really doing much C sharp any longer. As opposed to this, in the C++ samples that particular bit is much more straightforward, just like everything is much more straightforward in C++, so basically there is no messing around with it:

 

// macro to simplify interfaces management

#define CleanupInterface( pInterface ) \

{ \

if( pInterface ) \

{ \

pInterface->Release(); \

pInterface = NULL; \

} \

}

...

CSimpDgnDlg::~CSimpDgnDlg()

{

CleanupInterface( m_pIDgnDictEditTop );

CleanupInterface( m_pIDgnDictEditBottom );

CleanupInterface( m_pIDgnVoiceCmd );

CleanupInterface( m_pIDgnVMenu );

}



-------------------------

 02/10/2012 03:42 PM
User is offline View Users Profile Print this message


Wade Hatler
New Member

Posts: 9
Joined: 07/04/2009

I'm sorry that I don't think my original post was clear enough.  I greatly simplified the code down to the essentials which I think was confusing.  I am actually doing all of the cleanup mentioned in two different versions of my application written in two different languages.  One is C#, and the other is a tool similar to VBScript.

I actually don't have any problem at all with the happy path where my cleanup code executes.  I do the steps that are mentioned above, and even if you skip all of them except the one I put in my sample it always works fine as long as you at least un-register the menu.  So for the happy path, always good and reasonably easy.

Where I have a problem is when the program crashes prematurely, or I'm debugging and terminate the process. I was hoping to find a way to recover from that situation, but I haven't come up with anything yet.

I'm afraid I don't actually have the SDK so I haven't seen those samples.  The product on creating only needs to work with Dragon Medical, so I don't really need the SDK and it's fairly expensive.  That means I don't have any half decent examples.  Does anybody know where I can obtain better samples besides the SDK?

Thanks for all the replies.  They've been very helpful.

 



-------------------------
Wade Hatler
Statistics
28501 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 3 users logged in.
The most users ever online was 2028 on 04/05/2013 at 07:36 PM.
There are currently 93 guests browsing this forum, which makes a total of 96 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2014 FuseTalk™ Inc. All rights reserved.