.NET Framework Bookmark and Share   
 index > 64-Bit .NET Framework Development > OS 64bit + MOSS 64bit + VS2008 = System.BadImageFormatException
 

OS 64bit + MOSS 64bit + VS2008 = System.BadImageFormatException

I'm trying to make a simpleweb user control butwhen I add a SharePoint component such as Microsoft.Office.Server I get this error when I debug/release it:

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format.

When I add Microsoft.SharePoint (Windows SharePoint Services) to my references I get almost the same error : Could not load file or assembly 'Microsoft.SharePoint.Search......
The webpart with the web user control doesn't work either in a SharePoint site.
I've googled alot on this problem which clearlyhas to do with the 64 bit environment. I tried alot too but no luck.
What shall I try next?
  • Edited byLahey Thursday, April 16, 2009 11:31 AM
  •  
Lahey
Your assumption is incorrect, that's what the exception is telling you. Microsoft uses the amd64 architecture name for x64 code. That's historically correct, it was invented by AMD, not by Intel. Intel's version of a 64-bit processor was the infamous Titanium. Its architecture name is ia64.
Hans Passant.
nobugz
Yes. You cannot load 32-bit components into a 64-bit program. Microsoft Office is still only available in 32-bit, I assume it is the same for SharePoint. Ask questions about SharePoint in a SP forum. Find out how to force your web server to run in 32-bit mode at forums.iis.net
Hans Passant.
nobugz
Thanks for your reply,

I am uncertain what you mean with "You cannot load 32-bit components into a 64-bit program". What 32-bit components? I mean, I assume that the SharePoint components are 64-bit.

Also to add a strange thing..... The processorarchitecture of Microsoft.Office.Server.Search and Microsoft.SharePoint.Search in the GAC are AMD64. Which is weird because my server has an IntelXEON processor. But I am uncertain if GAC has influence over this anyway, since the dll's that sharepoint uses are in 12/ISAPI.
Lahey
Your assumption is incorrect, that's what the exception is telling you. Microsoft uses the amd64 architecture name for x64 code. That's historically correct, it was invented by AMD, not by Intel. Intel's version of a 64-bit processor was the infamous Titanium. Its architecture name is ia64.
Hans Passant.
nobugz
Hans,
SharePoint and the referred to assembly are both available in 64 bit and were at the release of SharePoint 2007. In fact, SharePoint 2010 will require 64bit.
The problem is related to the fact that Visual Studio is a 32bit process. The asp.net compiler used in the IDE is 32bit, but it is attempting to use the 64bit only assembly installed on the 64bit machine.
You can read more on the following MSDN post, Referencing Sharepoint Assemblies on x64bit Installs causes build errors for ASP.NET apps (in VS.NET 2005). Note, the MSDN Post references VS 2005, but I can verifythe same is true in 2008 and you can read another's comment on the same.
Tom
Tom Resing's SharePoint Blog
http://blogs.microlinkllc.com/tresing
Tom Resing

I want to connect this topic to the other topic I made in another section. This topic has simple "solution" may the solution above not work:
http://social.technet.microsoft.com/Forums/en-US/sharepointdevelopment/thread/b31e1f95-3288-4809-a37a-d7bfd10277d5

Lahey

You can use google to search for other answers

Custom Search

More Threads

• Type conversion error
• Microsoft JET 4.0 for Windows XP x64
• How to determine if running on 64Bit?
• Forms: Multi-Line text-box renders as disabled when mouse hovers over it.
• Thread corruption issues with 64 bit framework?
• using x64 COM Dll in VB.NET
• System.AccessViolationException in System.Collections.Generic.List`1.Enumerator.MoveNext() in IIS6
• how to know whether an os is 32 bit or 64 bit
• Reading access(X86) and writing to oracle(X64) from the same app on an X64 machine?
• System.AccessViolationException & FatalExecutionEngineError on vista 64 bit OS