Search This Blog

Monday, July 25, 2011

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


If you like this article, please click on +1 button and share with your friends.

Click here for the Video Tutorial of this article.
visit www.iGnani.com


Error:

Today I faced a very strange problem. While working on my project, at one point where my code was calling a method from the same class I got this error.

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

I can say confidently that I took this project from another development and there the code executed without any issues. Here, when I tried to call a particular method, without even entering the method, it used to throw the above error.




To give a brief about the project. It is a WindowsService application that uses a 32bit C++ library to get some work done. The machine where I had this code working is Windows 7 32bit, while the new machine was running Windows 7 64bit.


I spent quite some time debugging this issue without any end and finally was able to find a solution which turned out to be pretty simple, but something I usually used to overlook.


The problem had to with the 32bit and 64bit versions of Windows, but that was not to be blamed completely. In my Visual Studio I had the Solution Configuration set to “Debug” mode and Solution Platform set to “Any CPU”. Since the OS on the new machine was 64bit, it started executing it in 64bit mode while the 32bit C++ library was not ready to accept this, which created all the problem.


Solution


Change the Solution Platform to “x86”  and your application starts to execute without this above mentioned error.


Solution for a Web Application



While looking for solution for my issue, I also found that the same error will also occur in case of a Web based application or Web Site development. The case may be where in you were earlier developing using a 32bit and now moving to 64bit also. In this case you will have to change the settings in IIS.



  1. Inside IIS (7) click on Application Pools.
  2. Find the Application Pool that is configured for your web application in the list.
  3. Select it, then click Advanced Settings on the right.
  4. Second setting in the list: Enable 32-Bit Applications - must be set to True.

Hope this solution saves you some time in solving the problem.


Cheers!!!!!






visit www.iGnani.com


MicroMind Information Systems
#4013, K.R. Road, Banashankari II Stage,
BANGALORE - 560070
KARNATAKA, INDIA
Phone: +91 80 26762747



Technorati Tags: , , , , , , , , , ,
Blogger Labels: Exception, HRESULT, Error, WindowsService, library, Windows, Configuration, Debug, Platform, Application, Pools

No comments:

Post a Comment