CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Aug 2010
    Posts
    47

    Question Debug a Native DLL written in VC++.NET 2010 Express called from a VB.NET .exe file

    The saga continues. Sometimes I think I must be the first person in the world to convert a VB6 project that calls a VC++ DLL into the new and exciting (ie really irritating) .net versions, namely vb.net and vc++.net

    In VC++ 6.0 you could set the debug version of the calling VB6 .exe and then trace it through the dll step by step like this:

    Project --> Settings --> Debug --> Executable for Debug Session

    Now,according to Microsoft you cannot do this in 2010 Express version of vc++.net but you CAN (they say) put a break in the vc++.net dll then start your exe in vb.net and it will step into it

    Well, when I try it, it does NOT go into the DLL when I press F8 - anybody know the trick?

    (I am using 2010 Express because I am on XP because I still need VB6 and it will not install the VB6 IDE in Win 7/8)

    Edit:
    Well, it seems that in vb.net, if you right click when you get to the line of code that calls the function in your dll, you get the following option (in my case):

    Step Into Specific: MOPEKS.prjDLLs.TestF

    where "MOPEKS.prjDLLs" is the module in my code that includes TestF. So, I do this and press it, whereupon, according to Microsoft it should go into the function TestF. Of course, it doesn't but this does sound like progress of a sort

    Here is MS on the subject from:

    http://msdn.microsoft.com/en-us/libr...=vs.90%29.aspx

    To step into a specific function

    Advance the execution point to the function call you want to step into. (You might use a breakpoint, Step Into, Step Over, or Run To Cursor.)

    Right-click the source window to open the shortcut menu.

    Click Step Into Specific and choose the function you want from the submenu.

    The debugger executes the function call and breaks at the beginning of the selected function. The Step Into Specific command appears only if the execution point is located on a line of code that contains a nested function.


    I have a horrible feeling that maybe it is disabled in the Freebie versions (ie Express 2010 in my case)
    Last edited by wavering; August 7th, 2014 at 07:34 AM.
    MOPEKS - a freeware program that generates programs that use each other to solve problems. Is this the correct route to a genuinely intelligent machine?

  2. #2
    Join Date
    Jul 2002
    Posts
    2,543

    Re: Debug a Native DLL written in VC++.NET 2010 Express called from a VB.NET .exe fil

    Debugging from VB .NET, ensure that debugger type is Mixed.

  3. #3
    Join Date
    Aug 2010
    Posts
    47

    Re: Debug a Native DLL written in VC++.NET 2010 Express called from a VB.NET .exe fil

    Yes, I have tried this and still cannot get into the DLL ... but thanks for the suggestion
    MOPEKS - a freeware program that generates programs that use each other to solve problems. Is this the correct route to a genuinely intelligent machine?

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Debug a Native DLL written in VC++.NET 2010 Express called from a VB.NET .exe fil

    You need to make sure you deal with correct dll.

    Set your dll as default project in the solution. Specify the path to your VB.NET exe for running dll project. Set a breakpoint in dll code. Run the debugging session and see if the breakpoint activates (becomes bold). In case it's not (breakpoint bullet remains hollow), your exe loads similar dll from somewhere else. You can find out the location from Modules pane.
    Best regards,
    Igor

  5. #5
    Join Date
    Aug 2010
    Posts
    47

    Re: Debug a Native DLL written in VC++.NET 2010 Express called from a VB.NET .exe fil

    Quote Originally Posted by Igor Vartanov View Post
    You need to make sure you deal with correct dll.
    Yes, I really, really do have the correct version of the DLL

    Quote Originally Posted by Igor Vartanov View Post
    Set your dll as default project in the solution.
    I don't understand ...

    Quote Originally Posted by Igor Vartanov View Post
    Specify the path to your VB.NET exe for running dll project.
    How do I do that? If you can answer that for VC++.net 2010 Express I will be eternally grateful ...

    Quote Originally Posted by Igor Vartanov View Post
    Set a breakpoint in dll code. Run the debugging session and see if the breakpoint activates (becomes bold).
    Yes, been doing that ...

    Quote Originally Posted by Igor Vartanov View Post
    In case it's not (breakpoint bullet remains hollow), your exe loads similar dll from somewhere else. You can find out the location from Modules pane.
    I am confident it is the correct debug version of the DLL (I make minor changes in the function in the DLL and when I call from the vb.net exe the result is correct.)

    Thanks for your help ... !
    MOPEKS - a freeware program that generates programs that use each other to solve problems. Is this the correct route to a genuinely intelligent machine?

  6. #6
    Join Date
    Apr 2000
    Location
    Belgium (Europe)
    Posts
    4,626

    Re: Debug a Native DLL written in VC++.NET 2010 Express called from a VB.NET .exe fil

    Put your vb app and your vc dll into the same solution.
    set the VB app as default
    open the source for the VC dll
    set the breakpoint where you want
    'debug'

  7. #7
    Join Date
    Aug 2010
    Posts
    47

    Re: Debug a Native DLL written in VC++.NET 2010 Express called from a VB.NET .exe fil

    Quote Originally Posted by OReubens View Post
    Put your vb app and your vc dll into the same solution.
    Not sure how to do that ... I have already tried adding the vb.net exe file into the vc++.net source files. That did not work but maybe there are subtleties here ... ? I suspect the vb.net pdb file is needed ?
    MOPEKS - a freeware program that generates programs that use each other to solve problems. Is this the correct route to a genuinely intelligent machine?

  8. #8
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: Debug a Native DLL written in VC++.NET 2010 Express called from a VB.NET .exe fil

    Quote Originally Posted by wavering View Post
    The saga continues. Sometimes I think I must be the first person in the world to convert a VB6 project that calls a VC++ DLL into the new and exciting (ie really irritating) .net versions, namely vb.net and vc++.net
    What new and exciting .net versions? Are you referring to the Visual Studio versions that came out 14 years ago?

    At any rate, zip up the solution with the vb.net and dll projects and post it here. That way we can see how you organized your solution and don't have to guess or ask you 100 questions on how you've set things up.

  9. #9
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Debug a Native DLL written in VC++.NET 2010 Express called from a VB.NET .exe fil

    Quote Originally Posted by wavering View Post
    I don't understand ...

    How do I do that? If you can answer that for VC++.net 2010 Express
    I never use Express versions, so I would not help you with this. However, debugging DLL project did not change since at least VC++4 when I built my first DLL. You start Debug on DLL project, and IDE asks you about what exe to run. All you need is to provide the path to exe that loads your DLL.

    Another approach is to run your exe out of IDE and attach debugger to the running process. I'm absolutely sure you can find detailed instructions in MS support knowledge base regarding DLL debugging.
    Best regards,
    Igor

  10. #10
    Join Date
    Aug 2010
    Posts
    47

    Re: Debug a Native DLL written in VC++.NET 2010 Express called from a VB.NET .exe fil

    Quote Originally Posted by Igor Vartanov View Post
    I never use Express versions, so I would not help you with this. However, debugging DLL project did not change since at least VC++4 when I built my first DLL. You start Debug on DLL project, and IDE asks you about what exe to run.
    MS says this has been DELIBERATELY removed in the Express versions. I can do this with VC++ 6.0 and have done so for years

    Quote Originally Posted by Igor Vartanov View Post
    Another approach is to run your exe out of IDE and attach debugger to the running process. I'm absolutely sure you can find detailed instructions in MS support knowledge base regarding DLL debugging.
    That is what I have been trying to do for several days ... but thanks!
    MOPEKS - a freeware program that generates programs that use each other to solve problems. Is this the correct route to a genuinely intelligent machine?

  11. #11
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Debug a Native DLL written in VC++.NET 2010 Express called from a VB.NET .exe fil

    Quote Originally Posted by wavering View Post
    That is what I have been trying to do for several days ... but thanks!
    Then next your try should be with DebugBreak.

    Ultimately you always can debug with OutputDebugString or even with logging to a plain text file.
    Best regards,
    Igor

  12. #12
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: Debug a Native DLL written in VC++.NET 2010 Express called from a VB.NET .exe fil

    Quote Originally Posted by wavering View Post
    MS says this has been DELIBERATELY removed in the Express versions.
    How thoughtful of them.

    Anyway, today I installed VS 2010 Express to one of my VMs. The sample project attached. First you build ConsoleApplication1 project (VB.NET exe), then you build test2010 project (VC++ DLL). In the latter you just press F5, and breakpoint hits in dlltest_w32.dll being loaded by ConsoleApplication1.exe.

    The trick in dll project is done by Debugging settings: $(OutDir)ConsoleApplication1.exe, precisely as it was explained before.

    There is another (C++) client in DLL solution. So, to some degree you may debug your DLL being driven by another client app alright.
    Attached Files Attached Files
    Best regards,
    Igor

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured