Solved

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

Posted on 2001-08-13
8
455 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
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…

863 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

25 Experts available now in Live!

Get 1:1 Help Now