November 2010 (1)
August 2010 (1)
July 2010 (1)
June 2010 (3)
July 2009 (3)
June 2009 (1)
May 2009 (1)
February 2009 (1)
January 2009 (1)
November 2008 (3)
October 2008 (4)
September 2008 (9)
August 2008 (6)
July 2008 (3)
June 2008 (3)
January 2008 (1)
November 2007 (2)
October 2007 (6)
September 2007 (5)
August 2007 (22)
July 2007 (6)
June 2007 (1)
May 2007 (3)
April 2007 (27)
March 2007 (8)
February 2007 (6)
September 2006 (2)
August 2006 (4)
July 2006 (9)
June 2006 (17)
May 2006 (20)
April 2006 (12)
March 2006 (9)
February 2006 (4)
January 2006 (3)
December 2005 (2)
November 2005 (4)
October 2005 (5)
September 2005 (37)
August 2005 (83)
July 2005 (6)

Active Directory / LDAP (0)
ASP.Net (19)
Blackberry Development (4)
c# (34)
c++ (3)
Code Camp (1)
Excel (1)
Exchange (3)
Front Page 2003 (6)
FTP User Editor (4)
HTML / CSS / DHTML (8)
IIS (146)
IIS - Log Parser (7)
IIS / FTP (12)
IIS / Tools / Administration (42)
IIS / Tools / Authentication (6)
IIS / Tools / Compression (8)
IIS / Tools / Crash & Hang (12)
IIS / Tools / ISAPI Filters (17)
IIS / Tools / Log Files (17)
IIS / Tools / Scripts (28)
IIS / Tools / Security (9)
IIS / Tools / SSL (6)
IIS 7 (3)
Internet Information Server (1)
Me (Chris Crowe) (6)
MIME Types (1)
Misc (72)
Oulook Express (2)
Silverlight (1)
SQL Server (27)
SQL Server CTE (1)
Vista (15)
Vista Gadgets (8)
Visual Studio (11)
Voice over BroadBand (1)
Windows (33)
Windows Powershell (3)
Windows Sharepoint Services (0)
Windows Sharepoint Services (15)
Windows Vista (14)
Wine Cellar (1)
WMI (8)

Archive

November 2007 (2)

Could not load file or assembly 'name' or one of its dependencies

Have you seen the following error?

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

I have seen these a few times lately and the cause is usually that you have the following configuration:

  • IIS running on a 64Bit Operating System
  • The Assembly DLL in question has been compiled for 32Bit - check the project properties under the build tab, if under platform target you have x86 then it is 32bit only.

    x86 

Why would you have a 32bit only DLL? well it could be that you are using something that is not 64bit compatible, such as MAPI or ODBC...

The real problem is that the 64Bit IIS machine is using an Application Pool that is not allowing a 32bit DLL to be processed.

Open IIS Manager and find the application pool for the site and select the Advanced Settings.

AppPoolAdvSettings

 

Notice that there is an option called "Enable 32-Bit Applications" this is the cause of the error. Enable this and you should be good to go.

Here is an example of the full error for this message.


Server Error in '/' Application.


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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.BadImageFormatException: Could not load file or assembly 'XMLView' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Assembly Load Trace: The following information can be helpful to determine why the assembly 'XMLView' could not be loaded.

=== Pre-bind state information === LOG: User = NT AUTHORITY\NETWORK SERVICE LOG: DisplayName = XMLView (Partial) LOG: Appbase = file:///C:/dev/Projects/OSCARUtils/ LOG: Initial PrivatePath = C:\dev\Projects\OSCARUtils\bin Calling assembly : (Unknown). === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\dev\Projects\OSCARUtils\web.config LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v2.0.50727\Aspnet.config LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config. LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind). LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/root/8a8c3f22/9d24bab0/XMLView.DLL. LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/Temporary ASP.NET Files/root/8a8c3f22/9d24bab0/XMLView/XMLView.DLL. LOG: Attempting download of new URL file:///C:/dev/Projects/OSCARUtils/bin/XMLView.DLL. ERR: Failed to complete setup of assembly (hr = 0x8007000b). Probing terminated.

Stack Trace:

[BadImageFormatException: Could not load file or assembly 'XMLView' or one of its dependencies. An attempt was made to load a program with an incorrect format.] System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0 System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +465 System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +181 System.Reflection.Assembly.Load(String assemblyString) +42 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +190 [ConfigurationErrorsException: Could not load file or assembly 'XMLView' or one of its dependencies. An attempt was made to load a program with an incorrect format.] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +3637752 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +397 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +155 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +36 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +235 System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +214 System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +57 System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +259 System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +406 System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +125 System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +203 System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +52 System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +50 System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +410 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +274

Version Information: Microsoft .NET Framework Version:2.0.50727.1378; ASP.NET Version:2.0.50727.1378

Code Camp 2007 - Christchurch -

I was approached by an attendee at the Christchurch Code Camp yesterday with question that at the time I could not answer -  I should have been able to answer but my brain was frazzled.

Question

What is the difference between a virtual directory and an application in IIS 7?

Answer

The correct answer is:

A Virtual Directory and an application allows you to create an alias for a physical folder that may actually reside in a different folder, or disk drive or even computer than the current physical path.

The difference with IIS 7 is that an Application allows you to specify a different Application Pool where as a Virtual Directory does not.

application

VirtualDirectory