Solved

Debug an VB OCX that in use in C++ program

Posted on 2001-08-13
8
473 Views
Last Modified: 2011-10-03
Hi,

I built a simple OCX in VB that should be used in a C++ project.
I built an MFC project with my OCX and compiled it to an exe file.

In order to debug the control, I wrote the exe file path
in the Start Program field in the project properies windows.

When I'm running the OCX from debug, it seems that it
does not runs the program.

I did the same with VB exe: Compiled an exe file with my OCX, and set it in the OCX Start Program.
I received the following message:
"Component ... or one of its dependencies not correctly
registered: a file is missing or invalid".

Any suggestions ?


Thanks
0
Comment
Question by:amavr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 8

Expert Comment

by:Dave_Greene
ID: 6380881
Make sure everything looks right in your project > References & Components.  If you see the Word "MISSING" that could be your point of error.
0
 
LVL 1

Expert Comment

by:eeevans
ID: 6381122
The only way I know to test a VB OCX is to create a project group with a test VB EXE project used as a "test harness."  The "test harness" doesn't have to be a duplication of your entire C++ app but it will need to put the control through all of the same paces that the C++ App is going to use.  If you join the msdn online site you might want to check out the following:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon98/html/vbconprojectoptionsforolecontrols.asp


Hope this helps,

eeevans
0
 
LVL 2

Expert Comment

by:agriggs
ID: 6382868
You can debug Visual Basic and Visual C++ code in the Visual C++ debugger.  When compiling in VB, select Create Symbolic Debug Info option in compile options.  Then copy your code, and the resulting PDB file into the same directory where you have the OCX.  Then load one of your VB code modules into the VC++ IDE, and you can set breakpoints.  It's not quite as nice as VB debugger, because it doesn't understand some of the things that are going on, however, it can help in a lot of situations.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:amavr
ID: 6383324
Hi didn't understood the following:
How do I load my VB model to VC++ ?
What do I load ? one of the FRM's ? the VBP ?
What do I do with the PDB files ?

Thanks
0
 

Author Comment

by:amavr
ID: 6383415
Hi didn't understood the following:
How do I load my VB model to VC++ ?
What do I load ? one of the FRM's ? the VBP ?
What do I do with the PDB files ?

Thanks
0
 
LVL 2

Accepted Solution

by:
agriggs earned 100 total points
ID: 6384644
Copy the PDB file and any code you want to debug to the same directory as the compiled OCX (which they are probably already there anyway.)  Ok, now load Visual C++, and go ahead and load your C++ project.  Now, you can also load your VB code into the debugger, by selecting File...Open, then select "All files" from the dropdown box, then select any VB code modules that you want to debug.  If it is code for your OCX, then it is probably in a CTL file.  You can also debug CLS, FRM, and BAS files.  

You will need to scroll down through the file until you actually reach your code to get past the VB internal data structures.

You cannot actually set breakpoints until your OCX has been loaded because the debugger doesn't know what executable code to associate with the code on the screen.  Therefore, you will need to load the window that has your OCX sited on it before you can set breakpoints.

The PDB file is what actually tells the debugger what line of code to associate to a certain program counter in the compiled code, so it is necessary, but the debugger will look for it in the same directory as the compiled code, so you just need to leave it where VB put it.

I do this all of the time.  It is a little tricky, but it gives you tremendous power over just debugging VB.  Especially if you code in a mix of C++ and VB, like I do.

Give it a try and let me know what trouble you are having.

0
 
LVL 2

Expert Comment

by:JanusFury
ID: 6390554
I never knew that's what PDBs are for, should make debugging my VB game engine a lot easier when i jack up memory :)
0
 

Author Comment

by:amavr
ID: 6391611
I didn't knew it.

Thanks
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question