Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Need Debugging tips: MFC static library DLL

Need Debugging tips: MFC static library DLL

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpcomalgorithms
10 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Clark Kent123
    wrote on last edited by
    #1

    I have a C++ MFC static library dll file. I have a VB.Net program that acts as the GUI and C++ does the grunt work. I have just taken over this program, but never had an opportunity to do any debugging for the C++ part until today. Whenever I place a breakpoint in the cpp file and run the main program (VB) the breakpoint I placed in the cpp will not be hit according to the compiler. I am wondering why that is? In the past I have been able to do so on different programs but I believe that was because the C++ dll was created as a COM dll. I am not familiar with MFC so I am at a loss. By the way I have been searching but could not find any documentation on how to do this. Maybe there is so if you can point me in the right direction I would greatly appreciate that. Can the MFC static library be able to be debuggable from within a VB app? If not, can anyone offer any debugging suggestions as to some how "step" through the C++ code? If you need me to clarify anything or go into more depth I will gladly do so. By the way before I forget the C++ functions are called within VB using the following formula.

    Declare Function FunctionName Lib "DLL_Name.DLL" (parameters) As DataType

    L A 2 Replies Last reply
    0
    • C Clark Kent123

      I have a C++ MFC static library dll file. I have a VB.Net program that acts as the GUI and C++ does the grunt work. I have just taken over this program, but never had an opportunity to do any debugging for the C++ part until today. Whenever I place a breakpoint in the cpp file and run the main program (VB) the breakpoint I placed in the cpp will not be hit according to the compiler. I am wondering why that is? In the past I have been able to do so on different programs but I believe that was because the C++ dll was created as a COM dll. I am not familiar with MFC so I am at a loss. By the way I have been searching but could not find any documentation on how to do this. Maybe there is so if you can point me in the right direction I would greatly appreciate that. Can the MFC static library be able to be debuggable from within a VB app? If not, can anyone offer any debugging suggestions as to some how "step" through the C++ code? If you need me to clarify anything or go into more depth I will gladly do so. By the way before I forget the C++ functions are called within VB using the following formula.

      Declare Function FunctionName Lib "DLL_Name.DLL" (parameters) As DataType

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Clark Kent123 wrote:

      I have a C++ MFC static library dll file.

      DLL stands for Dynamic Link Library, it is by definition not static. Also, you state below that it is a COM component, are you sure it is built with MFC classes? You also need to check that the final component was built with DEBUG on so that the debugger can match the object code with the source file. You could test this further by setting a breakpoint in the VB code at the point where it calls one of the C++ functions and see if you can single step into the DLL.

      One of these days I'm going to think of a really clever signature.

      C 1 Reply Last reply
      0
      • L Lost User

        Clark Kent123 wrote:

        I have a C++ MFC static library dll file.

        DLL stands for Dynamic Link Library, it is by definition not static. Also, you state below that it is a COM component, are you sure it is built with MFC classes? You also need to check that the final component was built with DEBUG on so that the debugger can match the object code with the source file. You could test this further by setting a breakpoint in the VB code at the point where it calls one of the C++ functions and see if you can single step into the DLL.

        One of these days I'm going to think of a really clever signature.

        C Offline
        C Offline
        Clark Kent123
        wrote on last edited by
        #3

        Thanks for the response. It seems that I may need to clarify a few things. That is my fault. My original message may have skimmed over a few details. The reason why I wrote MFC static library was because under the C++ properties page I have the following... Configuration Type: Dynamic Link Library Use of MFC: Use MFC in a Static Library Use of ATL: Not using ATL I have not have had a chance to work with MFC and because of that I am at a loss. What I have worked on in the past (completely different program) is the use C++ to create COM objects and that way make it aware in other programming environments such as VB. But this particular C++ program is not a COM object. Every time I try to load the DLL file in VB using the Add Reference it tells me this is neither a valid COM object or assembly. I have not been in this situation before so this is left me scratching my head saying how do you debug this? Do you have any suggestions? This is what I am attempting to do. I have my main VB program and I add the C++ solution to the main project. I place break points in the C++ program and when I step through the main (VB) program it does not halt within the C++ cpp file. Upon mouse over the breakpoint the compiler tells me "The breakpoint will not be currently hit. No symbols have been loaded for this document." I made sure in the Configuration Manager that all the programs or solutions are defaulted to "Debug" setting. Any suggestions?

        D L 2 Replies Last reply
        0
        • C Clark Kent123

          Thanks for the response. It seems that I may need to clarify a few things. That is my fault. My original message may have skimmed over a few details. The reason why I wrote MFC static library was because under the C++ properties page I have the following... Configuration Type: Dynamic Link Library Use of MFC: Use MFC in a Static Library Use of ATL: Not using ATL I have not have had a chance to work with MFC and because of that I am at a loss. What I have worked on in the past (completely different program) is the use C++ to create COM objects and that way make it aware in other programming environments such as VB. But this particular C++ program is not a COM object. Every time I try to load the DLL file in VB using the Add Reference it tells me this is neither a valid COM object or assembly. I have not been in this situation before so this is left me scratching my head saying how do you debug this? Do you have any suggestions? This is what I am attempting to do. I have my main VB program and I add the C++ solution to the main project. I place break points in the C++ program and when I step through the main (VB) program it does not halt within the C++ cpp file. Upon mouse over the breakpoint the compiler tells me "The breakpoint will not be currently hit. No symbols have been loaded for this document." I made sure in the Configuration Manager that all the programs or solutions are defaulted to "Debug" setting. Any suggestions?

          D Offline
          D Offline
          David Knechtges
          wrote on last edited by
          #4

          One thing you could try is to set the C++ DLL as the start up project in your solution, get the VB program running, then attach the debugger to it. I have had success in the past doing that with C# and C++ DLLs.

          C 1 Reply Last reply
          0
          • C Clark Kent123

            Thanks for the response. It seems that I may need to clarify a few things. That is my fault. My original message may have skimmed over a few details. The reason why I wrote MFC static library was because under the C++ properties page I have the following... Configuration Type: Dynamic Link Library Use of MFC: Use MFC in a Static Library Use of ATL: Not using ATL I have not have had a chance to work with MFC and because of that I am at a loss. What I have worked on in the past (completely different program) is the use C++ to create COM objects and that way make it aware in other programming environments such as VB. But this particular C++ program is not a COM object. Every time I try to load the DLL file in VB using the Add Reference it tells me this is neither a valid COM object or assembly. I have not been in this situation before so this is left me scratching my head saying how do you debug this? Do you have any suggestions? This is what I am attempting to do. I have my main VB program and I add the C++ solution to the main project. I place break points in the C++ program and when I step through the main (VB) program it does not halt within the C++ cpp file. Upon mouse over the breakpoint the compiler tells me "The breakpoint will not be currently hit. No symbols have been loaded for this document." I made sure in the Configuration Manager that all the programs or solutions are defaulted to "Debug" setting. Any suggestions?

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            Clark Kent123 wrote:

            Every time I try to load the DLL file in VB using the Add Reference it tells me this is neither a valid COM object or assembly.

            So you are not even at the point of being able to debug anything yet, since you cannot get to the library. In order to use a C++ DLL from VB.NET you need to make that library into a COM component, or provide a pure Win32 interface which you can then access via the Platform Invoke feature[^].

            One of these days I'm going to think of a really clever signature.

            C 1 Reply Last reply
            0
            • L Lost User

              Clark Kent123 wrote:

              Every time I try to load the DLL file in VB using the Add Reference it tells me this is neither a valid COM object or assembly.

              So you are not even at the point of being able to debug anything yet, since you cannot get to the library. In order to use a C++ DLL from VB.NET you need to make that library into a COM component, or provide a pure Win32 interface which you can then access via the Platform Invoke feature[^].

              One of these days I'm going to think of a really clever signature.

              C Offline
              C Offline
              Clark Kent123
              wrote on last edited by
              #6

              I had a feeling you were going to say that. I was hoping that I was wrong. So because this DLL is not "exposed" it limits my debugging severely. :doh: This makes things interesting now. Thanks for confirming this for me.

              L 1 Reply Last reply
              0
              • D David Knechtges

                One thing you could try is to set the C++ DLL as the start up project in your solution, get the VB program running, then attach the debugger to it. I have had success in the past doing that with C# and C++ DLLs.

                C Offline
                C Offline
                Clark Kent123
                wrote on last edited by
                #7

                I will give this a try and hope this gets me what I need. Thanks for the suggestion!

                1 Reply Last reply
                0
                • C Clark Kent123

                  I had a feeling you were going to say that. I was hoping that I was wrong. So because this DLL is not "exposed" it limits my debugging severely. :doh: This makes things interesting now. Thanks for confirming this for me.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  Clark Kent123 wrote:

                  because this DLL is not "exposed" it limits my debugging severely

                  Well, more than that, it means you cannot even start to use it. As I said above you can only access it via COM, or through P/Invoke.

                  One of these days I'm going to think of a really clever signature.

                  C 1 Reply Last reply
                  0
                  • L Lost User

                    Clark Kent123 wrote:

                    because this DLL is not "exposed" it limits my debugging severely

                    Well, more than that, it means you cannot even start to use it. As I said above you can only access it via COM, or through P/Invoke.

                    One of these days I'm going to think of a really clever signature.

                    C Offline
                    C Offline
                    Clark Kent123
                    wrote on last edited by
                    #9

                    Yes, you are correct. In my VB program I am using the P/Invoke technique to call this library of C++ functions. But it's not fun that I can't debug it. :( Oh well. The original author did it this way and it's going to take so much work to make it a COM object. Not sure if I want to go down that path. But thanks for the info.

                    1 Reply Last reply
                    0
                    • C Clark Kent123

                      I have a C++ MFC static library dll file. I have a VB.Net program that acts as the GUI and C++ does the grunt work. I have just taken over this program, but never had an opportunity to do any debugging for the C++ part until today. Whenever I place a breakpoint in the cpp file and run the main program (VB) the breakpoint I placed in the cpp will not be hit according to the compiler. I am wondering why that is? In the past I have been able to do so on different programs but I believe that was because the C++ dll was created as a COM dll. I am not familiar with MFC so I am at a loss. By the way I have been searching but could not find any documentation on how to do this. Maybe there is so if you can point me in the right direction I would greatly appreciate that. Can the MFC static library be able to be debuggable from within a VB app? If not, can anyone offer any debugging suggestions as to some how "step" through the C++ code? If you need me to clarify anything or go into more depth I will gladly do so. By the way before I forget the C++ functions are called within VB using the following formula.

                      Declare Function FunctionName Lib "DLL_Name.DLL" (parameters) As DataType

                      A Offline
                      A Offline
                      Alan Balkany
                      wrote on last edited by
                      #10

                      "Whenever I place a breakpoint in the cpp file and run the main program (VB) the breakpoint I placed in the cpp will not be hit according to the compiler." When debugging managed code that calls unmanaged code, there's a setting (in Properties | Debug) called "Enable unmanaged code debugging". If this isn't checked, the debugger won't step into the unmanaged code.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups