views:

1033

answers:

7

Here is my setup:

Dev: - Windows Server 2008 64-bit - Visual Studio 2008 - Solution with 3 class libraries, 1 web application

Staging Web Server: - Windows Server 2008 R2 64-bit - IIS7.5 Integrated Application Pool with 32-bit Applications Enabled

In Visual Studio I have set all 4 of my projects to compile to 'Any CPU' but when I run this web application on the web server with the 32-bit application pool it times out and crashes. When I run the application pool in 64-bit mode it works fine. The production web server requires me to run 32-bit application pool in 64-bit OS which is why I have this configured in this way on the staging web server.

(I considered posting on ServerFault but the server part seems to be working fine. It is my code specifically that doesn't seem to want to run in 32-bit application pool which is why I am posting here.)

Edit: Event View Error

Faulting application name: w3wp.exe, version: 7.5.7600.16385, time stamp: 0x4a5bcd2b
Faulting module name: KERNELBASE.dll, version: 6.1.7600.16385, time stamp: 0x4a5bdbdf
Exception code: 0xe053534f
Fault offset: 0x0000b727
Faulting process id: 0x%9
Faulting application start time: 0x%10
Faulting application path: %11
Faulting module path: %12
Report Id: %13
+1  A: 

I guess 64-bit can run both 64-bit and 32-bit code but 32-bit can only run 32-bit code.

If you want to run the code compiled by the 64-bit compiler on 32-bit enabled box, you need to compile your code using a 32-bit compiler.

sza
+2  A: 

I had a similar error on an application that I was working on... if I built the assembly to target x86 it worked fine. I only had issues when I targeted "Any CPU".

Brian ONeil
I have seen this happen, as well. Normally, it happened when I had a 3rd party resource that had 32-bit assemblies. Not sure why - but this happened often when writing against the TFS 2008 API. I had to explicitly target x86, or it would give me random (and bizarre) failures.
joseph.ferris
+1  A: 

For each project, try the following:

1) Right mouse click on the project and select Properties.

2) Select the Build tab on left side

3) Select x86 for Platform target

4) Rebuild

JoseG
Yeah, I tried this. No luck.
Jeremy H
+1  A: 

I believe that error is indicative of trying to load a 64-bit dll into a 32-bit process. Your projects may all be set to "Any CPU" (or to x86), but I'm willing to bet that you're referencing a 64-bit dll. Are you using any 3rd party libraries for which you've included a 64-bit dll?

It's possible to swap 32-bit/64-bit references on-the-fly depending on the current machine's environment by modifying the .csproj files and using a bit of msbuild script. If you're interested in how this can be done, let me know and I'll post a follow-up.

David Mills
+1  A: 

Your post is a tad confusing.

Any CPU - X64 works?

Any CPU - X64+32bitCompat doesn't work?

If this is the case, it sounds like their is a discrepancy between the libraries being used. Perhaps the runtime is interpreting as x64 but being fed x86 libraries. It is important that they match.

You should create new configurations for both x64 and x86 (or just x86) and deploy them as needed. In my experiences, using 'Any CPU' leads down this bad and ugly road.

Krisc
+1  A: 

Sadly, I don't think there is any way someone here could have figured this out. Two DLLs I was using came from a downloaded ZIP file and when I went to the properties of those files there was a box that said they had been downloaded off the internet and I had to "unblock" them. Seems the 64-bit app pool did not honor this, but when I dropped to 32-bit it did. Once I "unblocked" the DLLs everything started working just fine.

Jeremy H
+1  A: 

Hi Jeremy,

We are doing the same thing by running the site in 32bit mode in IIS7 and getting same error. Can you explain the meaning of "unblock"?

Thanks, J

Singh