473,520 Members | 2,646 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

I have a mixed DLL (a managed DLL in C++ calling functions in other
unmanaged DLLs) which I can build successfully in Visual Studio 2005 but
can't reference as I get then immediately the error:

is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

Trying to find out what that actually means I read something that VS2005
will build a 32-bit or 64-bit DLL depending on what platform is used. As
I'm running a 32-bit Windows XP on a x64 CPU from AMD (with a target
platform "Win32" in VS2005) does it mean the DLL created is 64-bit? Or do
I have to look somewhere else to figure out what goes wrong here? By the
way, I had no problem to reference and load the DLL built in Visual Studio
2003. Building the code in VS2005 though causes a problem.

Boris
Aug 31 '07 #1
7 29356

"Boris" <bo***@gtemail.netwrote in message news:op.txxivc1445fww6@burk...
>I have a mixed DLL (a managed DLL in C++ calling functions in other
unmanaged DLLs) which I can build successfully in Visual Studio 2005 but
can't reference as I get then immediately the error:

is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

Trying to find out what that actually means I read something that VS2005
will build a 32-bit or 64-bit DLL depending on what platform is used. As
I'm running a 32-bit Windows XP on a x64 CPU from AMD (with a target
platform "Win32" in VS2005) does it mean the DLL created is 64-bit? Or do
If you're running 32-bit Windows, it is necessary that all your modules be
32-bit (or AnyCPU for MSIL), and I doubt the compiler would give you
anything else, regardless of your CPU.

Only when moving from 32-bit to 64-bit OS, you can run into some problems
because AnyCPU modules change automatically because they see the 64-bit .NET
installed, and then your 32-bit native DLLs break.

Aug 31 '07 #2
On Tue, 04 Sep 2007 19:19:48 +0300, Ben Voigt [C++ MVP]
<rb*@nospam.nospamwrote:
[...]If you aren't running XP 64-bit, then you don't have .NET 64-bit
and no
issues there.
Yes, only a 32-bit XP here.
Are you opening a mixed exe? For pure MSIL assemblies, you can
reference a
dll or exe. For mixed assemblies, you can only reference a dll, the exe
has
relocations disabled and some other optimizations that mean it MUST be
the
main program.
Yes, it's only a DLL. As I said the code was originally used to build a
DLL in VS2003 which worked fine. Meanwhile I tried to build the same code
(with Managed C++) in VS2005 and in another project with code converted to
C++/CLI - both doesn't work (or to be more precise: building works but not
referencing). As the error message doesn't contain any details I wonder if
there is anything else I can do except removing code, rebuilding the DLL
and checking if it can be referenced then. That would help at least to
find out which part of the code causes the problem?

Boris
Sep 4 '07 #3

"Boris" <bo***@gtemail.netwrote in message
news:op***************@burk.mshome.net...
On Tue, 04 Sep 2007 19:19:48 +0300, Ben Voigt [C++ MVP]
<rb*@nospam.nospamwrote:
>[...]If you aren't running XP 64-bit, then you don't have .NET 64-bit
and no
issues there.

Yes, only a 32-bit XP here.
>Are you opening a mixed exe? For pure MSIL assemblies, you can
reference a
dll or exe. For mixed assemblies, you can only reference a dll, the exe
has
relocations disabled and some other optimizations that mean it MUST be
the
main program.

Yes, it's only a DLL. As I said the code was originally used to build a
DLL in VS2003 which worked fine. Meanwhile I tried to build the same code
(with Managed C++) in VS2005 and in another project with code converted to
C++/CLI - both doesn't work (or to be more precise: building works but not
referencing). As the error message doesn't contain any details I wonder if
there is anything else I can do except removing code, rebuilding the DLL
and checking if it can be referenced then. That would help at least to
find out which part of the code causes the problem?
Any chance you're trying to use a reference to a .NET 2.0 assembly from a
..NET 1.x application? Check System::Environment::Version in your main
application.
Sep 4 '07 #4
On Thu, 06 Sep 2007 04:46:44 +0300, Ben Voigt [C++ MVP]
<rb*@nospam.nospamwrote:
[...]Can you post the complete stack trace of the exception? Turn on
first-chance exception debugging (Debug Exceptions -set that
exception
type to "thrown") as well, you may get better traces.

The purpose of this is to look up the code in .NET Reflector and see
under
what conditions the error is created... but Exception from HRESULT
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
Sep 6 '07 #5
On Thu, 06 Sep 2007 09:20:04 +0300, Boris <bo***@gtemail.netwrote:
[...]
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
Sep 7 '07 #6
On Thu, 06 Sep 2007 09:20:04 +0300, Boris <bo***@gtemail.netwrote:
[...]
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
Sep 9 '07 #7

"Boris" <bo***@gtemail.netwrote in message
news:op***************@burk.mshome.net...
On Thu, 06 Sep 2007 09:20:04 +0300, Boris <bo***@gtemail.netwrote:
>[...]

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?).
Try

#pragma managed(push, off)
#pragma managed(pop)

around the #includes for boost headers
>
Boris

Sep 10 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
12249
by: Mark Space | last post by:
Hi all, I followed some simple instructions to add python scrips to IIS as a cgi. The instructions were here: http://www.e-coli.net/pyiis.html Unfortunately, when I try to run a test script, I get this message displayed on my browser window: %1 is not a valid Win32 application.
1
2256
by: greg grosiak | last post by:
Hello, I am tring to downloand a character file from microsoft agent website. I download the animated character peedy and when I try and run the exec it gives me an error not a valid win32 application. What can I do to get this to run ?
1
7410
by: Pradeep D | last post by:
Hi, We have a .net dll, which has a wrapper to command line tool. When we try to call we enocunter this error. When we execute the same command from command line it executes without error. Can anyone help us out with this problem? Following is the error we encounter. "d:\iw-home\Teamsite\bin\iwgetfilejobs...
1
3953
by: Pradeep D | last post by:
Hi, We have a .net dll, which has a wrapper to command line tool. When we try to call we enocunter this error. When we execute the same command from command line it executes without error. Can anyone help us out with this problem? Following is the error we encounter. "d:\iw-home\Teamsite\bin\iwgetfilejobs...
0
1958
by: kk | last post by:
hello all, I want to call an exe(IISWeb.vbs) to create a site in Sharepoint.While calling that exe through Process.Start() it throws the following exception. 1.while calling through webService ,it throws the exception "ACCESS DENIED". 2.While calling through console Application,it throws
0
3205
by: Don MacKenzie | last post by:
Hi, I have a new development server that i put together on a Windows 2003 64 bit machine. I also have SQL Server 2005 and Developers Studio 2005 and 2003 installed on this machine. I have executed the "Enable32bitAppOnWin64 1" command, as per the instructions when installing Developers Studio. I am unable to server ASPX pages from this...
6
7096
by: =?Utf-8?B?TWVsaXNzYQ==?= | last post by:
I was having a problem on my computer and had to uninstall and re-install iis. Now I am trying to re-register asp.net using aspnet_regiis.exe -i but the computer just gives me the error message "c:\...\aspnet_regiis.exe is not a valid Win32 application" I am using Windows XP SP 2, .NET Framework 2.0
0
3286
by: Gianluca Pezzoli | last post by:
Hi, I have Windows Server 2003 x64 standard SP2 Italian, with Xeon 3.8 Ghz and 2GB RAM. On Server I found installed .net framework 1.1 and 2.0 (x64). I am developing a simple (Hello world) web service with Visual Studio 2008 Dev Edition (English). I have selected a Web Service Site Project with net 2.0 framework.
2
4764
by: jake | last post by:
I am new to web development. I published a VS 2008 web page (default.aspx) file (along with its .cs file), using the "Publish Web Site" feature, to a Windows 2003 server that has all the .Net Framework versions including 3.5. The web page does not have any code in the page_load event (in the .cs file) The default.html version of the same...
0
7326
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7238
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7210
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7593
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5769
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3298
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1683
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
857
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
531
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.