3

How can I debug a scenario where a Visual C++ 2010 SP1 application is unable to completely load its dependencies, and quits prematurely, without showing its UI?

I am interested in a good guides to Fusion Logs, dependency walker, and remote debugger, if you think they are relevant. Is it something that can be easily verified with WinDbg? What about Process Explorer?

Is it possible to launch a process on a remote machine with remote debugger attached?

Would it be possible to verify if a proper Visual C++ 2010 SP1 run-time is installed?

One limitation: the application runs fine on the developer's box with Visual Studio installed. Problem can only be observed on a clean target machine. This means that problem might disappear when a tool chain is installed.

skaffman
  • 398,947
  • 96
  • 818
  • 769
GregC
  • 7,737
  • 2
  • 53
  • 67

3 Answers3

7

I always check dll-dependency issue by DependencyWalker and then using the Global Flags Editor gFlags.exe, in the "Image File" tab, setup your program and check "Show loader snaps".

When your programs runs, WinDbg.exe should output lots of DLL loading messages, from them, with the help of dependencyWalker along with your source code(if you use LoadLibrary), you should be able find out where goes wrong.

sgryzko
  • 2,397
  • 2
  • 22
  • 37
Peter
  • 1,048
  • 10
  • 23
  • 2
    Another vote for "Show loader snaps". You'll learn more than you ever wanted to know about DLL load resolution. SxsTrace will also show details of side-by-side DLL loading without a debugger, and will quickly reveal if the C runtimes are missing. – Gary Kratkin May 07 '11 at 03:29
  • 1
    The reference to Dependency Walker should probably be accompanied with a big warning sign, that it isn't reliable anymore. It hasn't been updated in years, and pretty much displays misleading information for any version of Windows 7 and up. – IInspectable Jun 28 '17 at 14:45
  • 1
    There is a modern alternative now: https://github.com/lucasg/Dependencies – CherryDT Apr 21 '20 at 20:23
2

See if the /VERBOSE switch can help you know which dependency the linker is trying to load and run when you build and start debugging the code.

If you use the /VERBOSE switch, basically the linker will write the messages to the output window about the libraries the linker is loading, which is also available in the build log so you can look in it for reference. This way if there is an error in loading a particular dependency MAY BE this might help you.

I have tried /VERBOSE when I had link errors and knew which dependency caused the problem in my code.

Refer http://msdn.microsoft.com/en-us/library/wdsk6as6(v=vs.80).aspx to check if this can help you.

aeon
  • 1,029
  • 2
  • 13
  • 23
1

Is it possible to launch a process on a remote machine with remote debugger attached?

Sure you can. For example in Visual Studio 2008, right-click your project -> Properties -> Configuration Properties -> Debugging, select "Remote Windows Debugger" in the "Debugger to launch" dropdown list. Then type the full path of your EXE on your remote machine and according arguments if any.

Before doing so, you need first run remote debugging monitor on your remote machine. Copy \Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86(or other platform) to your remote machine, and run msvsmon.exe.

Generally, if your application quits due to the missing of some static dependency, you can use dependency walker to check which one is missing.

Eric Z
  • 14,327
  • 7
  • 45
  • 69