?
Solved

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

Posted on 2001-08-13
8
Medium Priority
?
491 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
Technology Partners: 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 400 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 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