cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Debugging with Visual Studio 2010

Highlighted
Amethyst

Debugging with Visual Studio 2010

Hey everyone,

So i'm working with Creo 2 and Visual Studio 2010, and am trying to get my program to debug in an active session (as opposed to compiling the code, unlocking the DLL, and loading it into aux applications everytime ).

I've added my xtop.exe to my project's Debugging commands, (and have made sure to make Attach = Yes), however I seem to still be doing something wrong. IWhen I set break points in my code, even inside of user_initialize(), it returns that "The breakpoint will not currently be hit. No symbols have been loaded for this document." This makes me think that either a) I'm not including some file or setting in Creo that I should be, b) I have a VisualStudio setting that is not set properly, or c) I'm completely off track haha.

Regardless, if anyone has any experience with this, I could definitely use a hand getting it to connect

Thanks,

James

President & Founder
CadActive Technologies - www.cadactive.com
4 REPLIES 4

Re: Debugging with Visual Studio 2010

Hello James,

I didn't work on ProE since several month but I remember I had the same question/problem than you.

It appeared that even if my breakpoints are not loaded it worked as soon as I launched the my application...

I don't know if it helps...

Emilie

Re: Debugging with Visual Studio 2010

Hello!

With Wildfire 4 I do that day for day.

It works fine!

Your application is build with debug informaitons? (Debug configuration?)

Greetings Lars

Re: Debugging with Visual Studio 2010

Lars & Emilie,

Yes I believe that I am set up to build into debug configuration. However it doesn't necessarily tell me what is going wrong.

To clarify, I am trying to add a simple 'refit' function to my Toolkit commands, and then add that script to my ribbon. My script compiles without errors... but I really think I'm just doing something simple incorrectly.

#include "stdafx.h"

#define PRO_USE_VAR_ARGS 3

#include <ProToolkit.h>

#include <ProObjects.h>

#include <ProMdl.h>

#include <ProMenu.h>

#include <ProMenubar.h>

#include <ProMessage.h>

#include <ProUICmd.h>

#include <ProUIMessage.h>

#include <ProUtil.h>

#include <ProCore.h>

#include <ProArray.h>

#include <ProTKRunTime.h>

/*----------------------------------------*\

Declare Functions

\*----------------------------------------*/

extern "C" ProError LM_refit()

{

ProError err = PRO_TK_NO_ERROR;

err = ProViewRefit (NULL, NULL);

if(err != PRO_TK_NO_ERROR)

{

printf("error %i.\n",err);

}

else

{

printf("Terminate.\n");

}

return err;

}

/*==========================================================*\

Pro/TOOLKIT Required Functions

\*==========================================================*/

extern "C" int user_initialize()

{

ProError err = PRO_TK_NO_ERROR;

ProMode mode = PRO_MODE_UNUSED;

uiCmdCmdId cmd_id;

err = ProModeCurrentGet(&mode);

if(err == PRO_TK_NO_ERROR)

{

if(mode == PRO_TK_BAD_CONTEXT)

{

printf("ProModeCurrentGet error in user_initialize.\n");

}

}

//MessageBox(NULL, "Pro/Toolkit App", "proe", MB_OK);

err = ProCmdActionAdd("LM_refit",(uiCmdCmdActFn)LM_refit, uiProe2ndImmediate,(uiCmdAccessFn)ACCESS_AVAILABLE,PRO_B_TRUE, PRO_B_TRUE, &cmd_id);

err = ProCmdIconSet(cmd_id,"C:\\data\\Toolkit\\LM_scripts\\text\\resource\\smiley.gif");

err = ProCmdDesignate(cmd_id,"LM_REFIT_TEXT","LM_REFIT_HELP","LM_REFIT_DESCRIPTION",LM_TEXT);

return(0);

}

extern "C" void main(int argc, char *argv[])

{

ProToolkitMain (argc, argv);

return;

}

extern "C" void user_terminate()

{

ProError err = PRO_TK_NO_ERROR;

err = ProViewRefit (NULL, NULL);

}

I can compile this into a DLL, but when I add my "Refit Window" command to the toolbar, the error I recieve simply shuts down Creo, regardless of where I place my breakpoints. This is why I thought maybe I had something set up incorrectly... but it may just be my code?

add_to_ribbon.JPG

xtop_error.JPG

I looked up this error, and it seems to be related to having multiple thread processes... but I didn't think I was using multiple threads because I never did a ProEngineerMultithreadModeEnable()....

Any advice or experience you guys may have would be greatly appreciated!!

Thanks,

James

President & Founder
CadActive Technologies - www.cadactive.com

Re: Debugging with Visual Studio 2010

Got an answer from PTC tech support. Ends up it was an error in my code!

Previously, I had been defining my action as:

err = ProCmdActionAdd("LM_refit",(uiCmdCmdActFn)LM_refit, uiProe2ndImmediate,(uiCmdAccessFn)ACCESS_AVAILABLE,PRO_B_TRUE, PRO_B_TRUE, &cmd_id);

The problem with this was that ACCESS_AVAILABLE needed to be the RESULT of the uiCmdAccessFn (aka, a function that responds with what the proper access should be). So the proper result would be something like:

Err = ProCmdActionAdd("LM_refit", (uiCmdCmdActFn) LM_refit,(uiCmdPriority) uiProe2ndImmediate, (uiCmdAccessFn) ToolkitMenuAccess, PRO_B_TRUE, PRO_B_TRUE, &cmd_id);

------------------- where there exists a separate function ------------------------------------------------

uiCmdAccessState ToolkitMenuAccess(uiCmdAccessMode access_mode)

{

return ACCESS_AVAILABLE;

}

So ultimately, where I thought my code wasn't debugging properly because of an improper setup, it really WAS set up properly the whole time, and I simply had an error in my code that was going unnoticed... so I'm going to call it a "beginner's mistake" haha.

Thanks for everyone's help!!

President & Founder
CadActive Technologies - www.cadactive.com