Projects in Visual C++ 2010 – Part 1: Creating a DLL project

When you write software, you often/sometimes divide your project into several subprojects. This mini series describes how to do this with Visual C++ 2010 (but this first part also applies to earlier versions). We start with creating a library project in form of a DLL.

Related articles:

Read more →

Projects in Visual C++ 2010 – Part 2: Project Dependencies

This article is the second part of the subprojects mini series. The first part was about creating a DLL project. This part will show how to use a DLL library project in another project.

Referencing a library in C++ (or, more specific, with Visual C++) is somewhat cumbersome – or should I say, used to be somewhat cumbersome. Fortunately, with the release of Visual C++ 2010 this has been greatly simplified. This article first shows the old way and then describes the new (simple) way.

Related Articles:

Read more →

Hunting DLL loading errors

Today I tried the software I’ve been writing on another computer – and it immediately crashed. I got this error message:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly ‘TrackerInterface-Mixed-Full.dll’ or one of its dependencies. The specified module could not be found.

Here, it tells me that my DLL “TrackerInterface-Mixed-Full.dll” could not be loaded. The first thing I thought was that the application couldn’t locate this DLL – because of the FileNotFoundException. Unfortunately this wasn’t the problem.

So I figured “or one of its dependencies” was the real problem. However, the error message doesn’t tell you what dependency (DLL) is actually missing – even when debugging.

So, I did some searching and found the Assembly Binding Log Viewer (or “Fusion Log Viewer”) which comes with Visual Studio. Unfortunately it didn’t do what I needed. It seems that this is actually more for .NET assemblies rather than native DLLs. (You need to run it with Adminstrator rights; otherwise it won’t work. Just in case you’ll ever need it.)

After some more searching I found a tool called Dependency Walker. And that’s exactly what did the trick. So I opened “TrackerInterface-Mixed-Full.dll” with it and got the following result:

Dependency Walker output with missing DLLs

Here you have my “TrackerInterface-Mixed-Full.dll” at the top of the tree and its dependencies listed below it. For one, you can see immediately that the file “QTCORED4.DLL” is missing. But you can also see that one dependency (“MAPPARSERD1.DLL”) is missing some dependencies as well. (Fortunately, Dependency Walker automatically expands all dependencies that again have missing dependencies.)

I hope this helps in case you’re running into this problem yourself.

Note: The part “The specified module could not be found.” of the error message indicates some missing DLLs. There can be other reasons for getting a “Could not load file or assembly ‘Assembly.dll’ or one of its dependencies.” which then have other texts after this one.

Note 2: This only seems to happen when using native DLLs from .NET applications/assemblies.