Debugging VB6 Code From Visual Studio 2012 - debugging

We have a .NET application using a lot of legacy components written in VB6. We were able to debug the VB6 code using native code debugger and generated pdb files in Visual Studio 2010. After upgrading to the VS 2012 (including Update 2) we cannot do this.
The module window shows following message:
Binary was not built with debug information.
You can also find following message in the output window:
Module was built without symbols.
When I try to load symbols manually, I get following message:
A matching symbol file was not found in this folder.
Debugging the very same dll or exe from VS 2010 works fine.
Is there any option to enable it?

I found a solution that works on my machine (per Microsoft's comments on ScottG's paid support request - thanks, Scott). Apparently Visual Studio's default debugger after 2010 doesn't handle VB6 DLLs, but there's a checkbox to use the old debug engine, which does:
I didn't need to enable Native Edit and Continue.

I have finally found how to enable debugging VB6 components using Visual Studio 2012. In short, you have to enable the old pdb format first by setting Options | Debugging | Edit and Continue | Enable native Edit and Continue and then you can attach to the dllhost.exe as usually.

In VS 2015 Tools->Options->Debugging->General, select 'Use Native Compatibility Mode'. It sucks that I still need to debug VB6, but I am thankful that I am still able to.

it seems that VS 2012 use msdia110.dll to decode symbol files, there's a DIA SDK sample in VS folder, you can test whether it can parse those VB pdb files. if it can't, i guess the new version DIA does not support old version pdb any more.

Related

On Visual Studio 2019, how to debug pure C++ and CLI C++ in a C++ Debug program?

I want to debug a C++ MFC/CLI program developped on Visual Studio 2019.
Until now, I can debug C++ native (MFC) code.
DebugType in Debug panel is set to Auto.
All breakpoints in C++/CLI modules are flagged as inactive (a red circle with an interrogation character in a yellow triangle).
After having changed DebugType from Auto to 'Mixed (.Net Framework), Visual Studio, when starting a debug session, is displaying following warning box.
But my build is in DEBUG mode !
What is happening ?
What must I do to debug pure C++ AND CLI C++ code ?
PS: I have also tried to debug in only C++/CLI code, but Visual Studio 2019 is displaying same message !
On Visual Studio 2019, how to debug pure C++ and CLI C++ in a C++
Debug program?
Since I do not have your project and cannot troubleshoot the issue quickly unless you provide a sample.
You can try the following suggestions:
Suggestions
1) try to reset all settings by Tools-->Import and Export Settings-->Reset All Settings
2) disable any third party extensions under Extensions-->Manage Extensions in case one of them causes the behavior.
3) check Use Managed Compatibility Mode option, Enable .NET Framework source stepping option and Suppress JIT optimization on module load (Managed only) option under Tools-->Options-->Debugging-->General.
4) close VS, delete .vs hidden folder, Debug folder from the solution folder and also Debug folder in the project folder. Then restart your project to test again.
I'm putting this here because it might help someone in the future, and because it's completely nuts.
I've followed all instructions I could find, including the ones on this question, reinstalled VS twice, with different versions, and nothing.
What solved for me was to simply delete the lines of code and write them again.
Yes.
I know.

Debugging into C++ DLL in VS 2013 Express Web

I'm developing a C# MVC project in Visual Studio 2013 Express for Web. An external C++ DLL is imported into the project and a function which is exported from the DLL is consumed.
I would like to be able to debug into the C++ DLL. However at the moment when I try to step into the function call the debugger steps over instead. The C++ DLL is one I created myself in Visual Studio 2013 Express for Windows Desktop. I have generated the .pdb debug symbols for the DLL and they are in the same folder as the DLL.
I have read in similar posts that suggest perhaps there is a properties setting to enable debugging into external an DLL. However in the MVC 5 project properties I can't find this option. In fact there doesn't even appear to be a debugging tab.
Is debugging into an external C++ DLL possible in Visual Studio 2013 Express for Web? If it is how do I enable this feature? If it is not possible, is there another Visual Studio Express where this is possible?
Thanks for your help!
I don't have VS Express, but the following applies to VS Professional and should apply to Express as well. You need to set your Debugger Type to Native Only (best, but then you have to break in the native code to debug it) or Mixed (may or may not work, I don't use it, so not sure it's limitations), and make sure the DLL is freshly build and matches the source code you have available. I suspect the setting you refer to is called 'Just My Code' (in Options->Debugging), but I don't think it matters in this case.
I'm not sure about VS2013 but with VS2015 you need to set "Enable Native Code Debugging". Right click on your C# project. In the right pane, click Debug. Under Enable Debuggers click the check box on Enable Native Code Debugging.

Visual Studio 2010 Pro, Prevent Debugging 3rd Party Controls

I want to prevent VS from attempting to debug code that is not mine. When I 'Step-Into' my code, VS tries to find resource files I don't have. I'm really not interested in viewing the 3rd party code code.
How can I only step through my managed code?
Followed this without success:
Restrict Visual Studio 2010 from debugging third-party DLL files
Also changed JIT debugging to Managed only.
Using breakpoints and step over.

Issues debugging Moles

I’m using visual studio 2008 and moles version 0.93. Everything works well except when I try to debug any test that uses a Moled type. The test skips all my breakpoints. And I get the following message in the output window:
Unable to attach. Check for one of the following.
The application you are trying to debug uses a version of the Microsoft .NET Framework that is not supported by the debugger.
The debugger has made an incorrect assumption about the Microsoft .NET Framework version your application is going to use.
The Microsoft .NET Framework version specified by you for debugging is incorrect
Please see the Visual Studio .NET debugger documentation for correctly specifying the Microsoft .NET Framework version your application is going to use for debugging.
If I try debbuger.Break () I get a message: "No symbols are loaded for any call stack frame. The source code cannot be displayed."
I’m in a crunch right now chasing an issue with one our main components and it has been a pain (like I need novocaine) trying to figure anything out without being able to step through the code.
I want to take advantage of mole's "smooth debugging experience". However, I can't seem to get the debugger to attach at all.
Thanks,
Bzz
See the solution to this issue here:
http://social.msdn.microsoft.com/Forums/en/pex/thread/91c08bf4-3260-458c-a221-91f030a75499
I had this problem when I moved a project from Visual Studio 2010 to Visual Studio 2008. Here's what I did to fix it.
Close Visual Studio. Navigate to the Debug/bin location. Delete the following files:
*.vshost.exe
*.vshost.exe.config
*.vshost.exe.manifest
Open the solution. Goto the project Settings. Under the Application Target Framework, select a framework lower than the one you are working with (you'll set it back later). Visual Studio will close and re-open your project automatically. Then set the Target Framework back to the original version you were working with. Rebuild all, and debugging will work properly.

How to use VB6 debugger on Outlook property page OCX?

Using VB6, I have created an Outlook plugin, that has a property page. The property page is an OCX control.
When I compile the project to an OCX file, and then run OUTLOOK, things work fine: I am able to see my OCX as a tab in the Outlook options.
However, when I try to debug by running the OCX in VB6 I get an error. My debugging is started like this:
1) Debug options set to Wait for components to be created"
2) F5-RUN project in VB6.
3) Start Outlook.
4) Get the error: "Cannot display "MyOcx" page. This page will remain visible, but is not available. An OLE registration error occurred. The program is not correctly installed. Run Setup again for the program"
I suspect this is because, when debugging, the OCX is being created out-of-proc and Outlook doesn't like that.
Is there a good technique to use the VB6 debugger on the OCX in this scenario?
The VB6 debugger is sometimes flaky when debugging DLLs or OCXs.
You could try Windbg, a free standalone debugger from Microsoft. Compile your VB6 OCX into native code with no optimisation and "create symbolic debug info" (i.e. create PDB files), and you will be able to debug your OCX in-process in Outlook. Here's a 2006 blog post by a Microsoft guy about using Windbg with VB6, and 2004 blog post by another Microsoft guy with a brief introduction to Windbg.
You could also use the Visual Studio 2008 debugger with VB6 and PDB files, e.g. with Visual C++ Express Edition (which is free). EDIT see Kris's answer for more details.
EDIT: Both Windbg and Visual Studio expect the source code to be in exactly the same path on the debug machine as it was on the build machine when the OCX was built. The easiest way is to build and debug on the same machine. Otherwise you might need to fiddle with SUBST to create virtual drives - or I'm told the serious way is to use a Symbol Server.
(Les serious) you could do without those newfangled interactive debuggers, just log to a file, or with DebugMessage calls from your VB6.
The only way you are really going to be able to Debug this is In Process as MarkJ said. Using the free Visual Studio 2008 C++ Express Edition (or even better, Visual Studio 2008 Professional if you have it, and it is available for a 90 day trial) and a PDB.
To make sure you are creating the PDB, go into Visual Basic, check the P)roject / P)roperties and click on the Compile tag. Make sure "Create Symbolic Debug Info" is checked.
Next start up Outlook, and attach to that process from Visual Studio (T)ools / Attach To Process. Make sure your Ocx is shown in the modules window, and then load the PDB (right click on the Ocx in the modules window). You will probably have to add the source code in the Solution Properties (for more details on how to do that, read this post).
It's a bit of a pain in the butt the first time, but once you can do it, it becomes pretty easy, and is far easier than trying to determine what is going on from a log.
I don't have much idea on the OCX.
However, you can use a tool which was part of visual studio named something like "activex control test tool".
As far as I know (based on my understanding of documentation), OCX is created in-proc.

Resources