Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Recommended Posts

  • 2 weeks later...
  • 4 weeks later...

Dear Sirs,

 

I guess I miss some general knowledge about debugging. I know what debugging is, but I have actually never used a debugger yet. So far I have been testing my programs this way:

1. Rebuild Solution in VS

2. Start Mastercam

3. Start C-Hook

4. Close Mastercam

I consider this way a little clumsy and besides it doesn't allow for debugging. I know there are two Mastercam.exe files, one for running Mastercam, the other for debugging C-Hooks, but I still don't understand how to use the latter.

 

So would you please explain clearly, how to properly set properties of a C# .NET project in VS in order to debug a C-Hook. Further, how to avoid restarting Mastercam each time one has to rebuild Solution in VS (return MC_RETURN.MC_UNLOADAPP; does not work).

 

Thank you in advance!

Link to comment
Share on other sites

In your Project ‘configuration properties’ with Debug as the active configuration, set:

 

For a C-Hook (C++) project ->

Command: c:mcamxsdkdebugmastercam.exe

Working Directory: c:mcamx

 

For a NET-Hook (C#) project ->

Debug Mode: Program

Start Application: c:mcamxsdkdebugmastercam.exe

Working Directory: c:mcamx

 

Of course if your X and/or the SDK is loaded in a different folder, you will need to adjust the paths stated above.

 

Now to run your project in Debug mode you select (on the VS menu) Debug – Start (or just use F5). The Mastercam (debug EXE) will startup and you then run your C-Hook from within Mastercam as usual and now you’re debugging! When you stop the debugger (Debug – Stop or Shift-F5) Mastercam will also shutdown. Make any changes needed in your project’s source code and hit F5 again to restart debugging.

 

F5 and Shift-F5 will become automatic in no time. wink.gif

 

return MC_RETURN.MC_UNLOADAPP;

 

This should work. (I’ve not used it)

Note – If you have an FT file that “loads” your DLL when Mastercam starts, this “unload” will not occur.

Link to comment
Share on other sites

Dear Mr. Martin,

 

thank you for your help. You really explained the way that anybody can understand, even me wink.gif It also seems to me that MR2 version works much better than MR1.

 

But I still didn't manage to produce the result I wanted. What happens, if I hit F5 is this: my code compiles and links, then "Watch 1" and "Output - Debug" windows are opened in VS. Afterwards Mastercam seem to start, but it doesn't really open and finally my VS is back to its initial state.

If I hit Ctrl+F5 (Start Without Debugging), then Mastercam does start, but I get this Error:

 

Debug.jpg

 

So, I'll try to live on without debugging for some more time smile.gif

Have a nice day!

Link to comment
Share on other sites

Hello Jure and Roger. I've been following this thread because I'm attempting to do the same thing. However I do not have a Debug folder. So I used the mastercam.exe in my mcamx folder. Then I configured as above.

 

After doing this I was able to hit Debug and VS looked like it was working, then Mastercam opened but it was blank, and VS didn't give me any useful debugging information.

Link to comment
Share on other sites

areenr,

 

Are you trying to debug a CHook or a NETHook?

 

If you have the CHook SDK, you should have the DEBUG version of mastercam.exe.

 

Anyway, you're not giving me much to go on...

quote:

then Mastercam opened but it was blank

"What is meant by "blank"?

Did X open and stay running?

 

quote:

VS didn't give me any useful debugging information

What is meant by this?

Were you able to execute your CHook (or NETHook) in X?

Link to comment
Share on other sites

Sorry about the lack of details Roger. Thanks for getting back.

 

1. I'm working with Chooks only, not NETHooks.

 

2. I only found "mastercam.exe" in my main mcamx folder. But did not see any DEBUG folder under the main folder. I do have the SDK installed.

 

3. I meant that Mastercam X opened (it was closed before I ran the debugger). But when it opened it did not have any information, or any file opened, it simply had an empty blue background screen. It did stay running though. But again, I think I used the regular mastercam.exe, not the debug version, which may be the reason for that.

 

4. As for VS not giving me any information, I was looking for it to perform the usual debug routine where I have options to step into and out of the file, and use breakpoints, etc... I did not try to execute the CHook after Mastercam opened. It sounds like I should have then tried to run it.

 

As always, I appreciate the help.

Link to comment
Share on other sites

1. I'm working with Chooks only, not NETHooks.

 

>> This can be important to know.

 

2. I only found "mastercam.exe" in my main mcamx folder. But did not see any DEBUG folder under the main folder. I do have the SDK installed.

 

>> Look for a DEBUG folder under the SDK folder.

 

3. I meant that Mastercam X opened (it was closed before I ran the debugger). But when it opened it did not have any information, or any file opened, it simply had an empty blue background screen. It did stay running though. But again, I think I used the regular mastercam.exe, not the debug version, which may be the reason for that.

 

>> Mastercam should look just like if you started it in the “usual manner”.

 

4. As for VS not giving me any information, I was looking for it to perform the usual debug routine where I have options to step into and out of the file, and use breakpoints, etc... I did not try to execute the CHook after Mastercam opened. It sounds like I should have then tried to run it.

 

>> Nothing “automatic” is going to happen. After X starts up, then you run your CHook and then VS can attach to your code and have the ability to show you debug info on your project.

Link to comment
Share on other sites

Thanks again for your help Roger, I made some stupid mistakes there and finally got the debugger working. bonk.gif

 

When I run the debugger, and as MCX starts up I get 3 popup error windows

 

1. "Could not find resource DLL: C:Program FilesmcamxsdkdebugResourcesrast2vecRes.dll

2. Same error but the dll is txtchainRes.dll

 

I looked and don't have a Resources folder, and I'm not sure why not.

 

3. Another Debug Assertion failure which I assume is a problem with my code. But the file is in a drive I don't have on my PC:

 

f:vs70builds3077vcMFCATLshipatlmfcincludeafxwin1.inl

 

This error is at Line:29

 

I have an option to Abort, Retry, or Ignore. If I Ignore I can go to Mastercam and it has an "Error Report Dialog" window. Then I check that and run my Chook. The output in VS shows the .dll files called as it starts Mastercam and it also shows that it loaded my Chook with "Symbols Loaded".

 

I have included the popups in a word document on the FTP if it helps to look at them called "Chook_Debugging" in the Chooks directory.

 

Thanks again for your help.

Link to comment
Share on other sites

I was able to copy from the main mcamx folder the folder "resources" over to the sdkdebug folder. So this took care of errors 1 and 2 above. But still get the 3rd error when starting debugging from visual studio .net 2003.

 

Also have not been able to get any of the breakpoints to stop the chook from running. I am a newbie, and not sure what lines are valid breakpoints. For instance I'd like to check the line:

 

in.open("axis_alignment.txt");

 

to see if the member function (?) "open" is actually opening my txt file. But with the breakpoint there all I get is a red circle with a question mark in it while debugging, and the chook executing.

Link to comment
Share on other sites

quote:

But the file is in a drive I don't have on my PC:

When you get a message such as this where VS references a file that is not part of your project, don’t worry about “where” is says the file resides as it lies. wink.gif

Look for these files under the ‘vc7’ folder of where you installed VS 2003 ->

Program FilesMicrosoft Visual Studio .NET 2003Vc7

I just do a Search-Files for the filename with the as the starting folder to be searched.

 

BTW, this is the code in afxwin1.inl that is referenced ->

 

 

_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetResourceHandle()

{ ASSERT(afxCurrentResourceHandle != NULL);

return afxCurrentResourceHandle; }

 

 

I know what it is complaining about and this does sound vaguely familiar.

But as I’m not really an MFC programmer I don’t have a “I know that” answer.

 

quote:

and not sure what lines are valid breakpoints.

Virtually any line of code is a valid breakpoint location.

 

quote:

But with the breakpoint there all I get is a red circle with a question mark in it while debugging, and the chook executing.

Somehow VS is not attaching to your DLL for debugging.

Link to comment
Share on other sites

Ahh, I'm so glad you said the last bit. I really was thinking the same thing, but didn't know enough to be sure.

 

I found the file here:

 

C:Program FilesMicrosoft Visual Studio .NET 2003Vc7atlmfcinclude

 

I opened the inline file, and found the excerpt that you copied. It was writen exactly as you had typed it above. I hope this helps so that we can get VS to correctly attach to my DLL.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...