Thursday, May 23, 2013

Checking if a DLL is 32bits.

So I was trying to deploy a web service in IIS, but I was getting the following error when I tried to access the service using IE.

"Could not load file or assembly 'myAssembly.name' or one of its dependencies. An attempt was made to load a program with an incorrect format body..."

I had seen this before. My file was inside IIS, so I knew the file was there, so one question remained. I am running pure 64bits, could this dll be compiled in 32bits only? I made the following test.

I went to IIS's "Application Polls" and found my service:


Then I changed the "Enable 32-Bit Applications from FALSE to TRUE.
And the amazing thing is that my service returned XML when I hit it with IIS.

Crap my DLL was really 32bits. But how to really check?

Here comes CorFlags:

By just finding the DLL using command line program for VS2010 (Visual Studio Command Prompt (2010). I normally search for "Prompt" and the program will display.

By running:
CorFlags myLibrary.DLL

The following showed up:
Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Version   : v2.0.50727
CLR Header: 2.5
PE        : PE32
CorFlags  : 11
ILONLY    : 1
32BIT     : 1
Signed    : 1


Just for kicks I ran on another library that I knew was 64bits:
Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Version   : v2.0.50727
CLR Header: 2.5
PE        : PE32
CorFlags  : 9
ILONLY    : 1
32BIT     : 0
Signed    : 1

So I need to go back to my compiler and make sure to compile in 64bits and try again.

God bless,
Bruno

No comments:

Post a Comment

Kitematic - Self Signed Certificate In Certificate Chain

Found this issue while behind a enterprise proxy. Proxy uses self signed certificate. Windows has the certificate as trusted, docker works f...