ASP.NET: Could not load file or assembly ‘Name’ or one of its dependencies.

Am facut un deploy cu o aplicatie ASP.NET pe un server pe care avem Windows Server 2008 R2 Datacenter, 64-bit.

Desi pe local aplicatia functiona bine, dupa deploy a aparut urmatoarea erroare:

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

Amluat la intrebari pe prietenul Google si zicea ca eroarile de genul acesta apar daca IIS-ul ruleaza pe un server 64-bit si aplicatia este setata sa faca build avand target platform 32-bit. (se poate verifica asta dand click dreapta pe project / Properties / Build. Daca acolo apare x86, nu-i bine. :D )

Ei, bine. La noi nu era target platform x86, in plus pe local mergea (si local avem tot OS pe 64-bit). DAR in project se folosea un dll care era pe 64-bit.

Ce-i de facut in cazul asta?

In cazul acesta, te duci fain-frumos pe server in IIS Manager la application pool-ul sub care ruleaza aplicatia, selectezi Advanced Settings si acolo gasesti setarea magica: „Enable 32-Bit Applications”.


Default este pe false. Am pus-o pe true si aplicatia a mers ca minunea. :D

Iata si un exemplu de erroare despre care vorbeam:

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

posted on Monday, November 05, 2007 2:49 PM |
Comentarii Facebook

6 Comments

Lasă un răspuns

Adresa ta de email nu va fi publicată. Câmpurile obligatorii sunt marcate cu *

 

Acest site folosește Akismet pentru a reduce spamul. Află cum sunt procesate datele comentariilor tale.