Solved

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

Posted on 2001-08-13
8
451 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
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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now