Solved

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

Posted on 2001-08-13
8
468 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…

856 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