473,855 Members | 2,068 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 29448

"Boris" <bo***@gtemail. netwrote in message news:op.txxivc1 445fww6@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.nos pamwrote:
[...]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.ms home.net...
On Tue, 04 Sep 2007 19:19:48 +0300, Ben Voigt [C++ MVP]
<rb*@nospam.nos pamwrote:
>[...]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::Environ ment::Version in your main
application.
Sep 4 '07 #4
On Thu, 06 Sep 2007 04:46:44 +0300, Ben Voigt [C++ MVP]
<rb*@nospam.nos pamwrote:
[...]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.BadImage FormatException 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.ms home.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
12274
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
2280
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
7442
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 "\default\main\APAC\English\Demo\WORKAREA\workarea\templatedata\ExternalContent\1IntelWeb\data\13190252\180313.xml" returns 1 :...
1
3994
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 "\default\main\APAC\English\Demo\WORKAREA\workarea\templatedata\ExternalContent\1IntelWeb\data\13190252\180313.xml" returns 1 :...
0
1982
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
3219
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 machine. I started with a "500 - Internal Server Error" but am now getting a "%1 is not a valid...
6
7115
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
3332
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
4779
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 aspx file works fine, but not default.aspx itself, which produces a "%1 is not a valid Win32...
0
9903
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9754
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11044
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10767
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9526
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7084
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5754
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4168
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3194
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.