当我尝试访问IIS 7.0中的网站(使用Windows Server 2008上的VSTS 2010 + .Net 4.0开发)中的网页(default.aspx)时,遇到以下错误消息。有什么不对?BadImageFormatException什么意思?
顺便说一句:我正在运行Windows Server 2008 64位(不是R2),并且尚未激活Windows Server 2008,它可能是一个根本原因吗?
[BadImageFormatException: Could not load file or assembly 'test.foo' or one of its dependencies. Try to load bad formatted program. ]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) +567
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +192
System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +118
[ConfigurationErrorsException: Could not load file or assembly 'test.foo' or one of its dependencies. Try to load bad formatted program. ]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +11392147
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +484
System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +127
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1087
[HttpException (0x80004005): Could not load file or assembly 'test.foo' or one of its dependencies. Try to load bad formatted program. ]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +11524352
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +4782309
发布于 2018-03-09 13:53:30
BadImageFormatException
升起时,文件可以被发现,但不是正确的组装,或已损坏。例如,如果将文件FTP到服务器并且传输中断,则DLL文件可能仅部分传输,导致发生此错误。
在64位与32位之间:当使用P / Invoke或COM Interop时,一些博客报告称切换到特定的目标编译可能会有助于情况。这意味着:如果你使用32位DLL进行接口,请确保你编译好了x86
,迫使它在WoW32下运行,否则你会收到这个异常。此修复程序在此处和此处得到确认。
或者,可以通过运行以下命令将整个系统设置为默认的32位:
Ldr64.exe setwow
从Framework64
目录中。
一个常见的解决方案是重建文件,或至少重新发布它。
发布于 2018-03-09 14:40:50
在将32位DLL部署到运行IIS 7的64位服务器上时,我刚刚得到了这一点。
为了解决这个问题,我必须在应用程序池的高级设置中将“启用32位应用程序”设置为True。
https://stackoverflow.com/questions/-100007569
复制相似问题