> [...]Can you post the complete stack trace of the exception? Turn on
> first-chance exception debugging (Debug > Exceptions -> set that
[quoted text clipped - 6 lines]
> strongly
> suggests nothing will be gained there.
Unfortunately you are right: Throwing System.BadImageFormatException and
the Win32 exception 0x800700C1 didn't reveal any details.
> Have you changed manifest options at all? Perhaps selected static use of
> runtime libraries (not compatible with .NET)?
All options in the C/C++ property page are set to default. In the linker
property page I had to add an additional dependency to an unmanaged
library from a third-party vendor (something I had to do for the VS2003
solution though, too). The Manifest Tool property page remained untouched.
Comparing the options with the VS2003 solution I see that I had added
additional dependencies to msvcrt(d).lib and mscoree.lib. If I'm not
mistaken they were required to fix the Mixed DLL problem in VS2003/.NET
1.1 and are not needed anymore for VS2005 solutions?
> Can .NET Reflector load the C++/CLI DLL?
Yes, that works. I can also use the class browser in VS2005.
Thanks for your help so far,
Boris
Boris - 07 Sep 2007 14:29 GMT
> [...]
I've been throwing everything away except one class which has only an
empty constructor. When I build the .NET DLL now there is basically no
code inside - but the problem remains.
Going once again through the project configuration I would guess that the
dependency on an unmanaged library causes the problem. Although the .NET
DLL currently does not call any functions in the unmanaged DLLs it depends
on I still have to add a dependency to the project configuration although
this library is only used by the unmanaged DLLs the .NET DLL depends on.
If I don't add the dependency I get "unresolved token" and "unresolved
extern symbol" errors. If I do the errors disappear and only a warning
"unresolved typeref token ...; image may not run" remains. That said I do
get a DLL then but it seems to be faulty.
Although I don't know if I'm on the right track I wonder if there is
anything to take care of when a managed DLL depends on an unmanaged
library?
Boris
Boris - 09 Sep 2007 15:50 GMT
> [...]
I found out what causes the problem (which doesn't mean though that I have
an idea how to solve it) and can now provide a reproducable test case. You
must have installed Boost 1.34.1 (see http://www.boost.org/) and add this
code to a C++/CLI project:
#pragma once
#include <boost/thread/mutex.hpp>
#using <mscorlib.dll>
using namespace System;
namespace MyNamespace
{
public ref class MyClass
{
public:
MyClass() { }
};
}
Including the header boost/thread/mutex.hpp makes it impossible to load
the DLL (yes, including is enough - no need to use any code from that
header). I probably have to submit a bug report to Boost (or Microsoft?).
Boris
Ben Voigt [C++ MVP] - 10 Sep 2007 14:52 GMT
>> [...]
>
[quoted text clipped - 21 lines]
> the DLL (yes, including is enough - no need to use any code from that
> header). I probably have to submit a bug report to Boost (or Microsoft?).
Try
#pragma managed(push, off)
#pragma managed(pop)
around the #includes for boost headers
> Boris