无法加载文件或程序集或其依赖项之一。试图加载格式不正确的程序
Could not load file or assembly or one of its dependencies. An attempt was made to load a program with an incorrect format
我有一个 ASP.NET MVC 4 Web Api 应用程序,在 Windows 7 Professional 64 位和 IIS 7.0 上部署了 .NET Framework 4.0 和 C#。
当我 运行 应用 http://myHost/WebApi 时,我得到这个:
Can not load file or assembly 'AutomationMiddleware.Common' or one of
its dependencies. An attempt was made to load a program with an
incorrect format. Description: An unhandled exception when running the
current web request. 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
'AutomationMiddleware.Common' or one of its dependencies. An attempt
was made to load a program with an incorrect format.
Source code error:
Has generated an uncontrolled 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.
Trail to load the assembly: The following information can be helpful
to determine why no assembly 'AutomationMiddleware.Common' was loaded.
The administrator assemblies are loaded from:
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll Running under
executable file c:\windows\system32\inetsrv\w3wp.exe
--- Register of detailed errors.
=== Status information prior link ===
LOG: DisplayName = AutomationMiddleware.Common
(Partial)
AVS: partial link information for an assembly is provided:
AVS: Assembly Name:. AutomationMiddleware.Common | Domain Id: 2
AVS: A partial bond occurs when only provides part of the display name of the assembly.
AVS: This may lead to an incorrect load linker assembly.
AVS: It is recommended to provide a textual identity completely specified for assembly,
AVS: consisting of simple name, version, culture, and public key token.
AVS: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this problem.
LOG: AppBase = file: /// C: / inetpub / wwwroot / WebAPI /
LOG: Initial privatePath = C: \ inetpub \ wwwroot \ WebAPI \ bin Assembly Call: (Unknown).
===
LOG: This link begins in the context of default load.
LOG: Using the configuration file of the application: C: \ inetpub \ wwwroot \ WebAPI \ web.config
LOG: Using host configuration file: C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ aspnet.config
LOG: Using machine configuration file in C: \ Windows \ Microsoft.NET \
Framework64 \ v4.0.30319 \ config \ machine.config.
LOG: The policy is not being applied to reference at this time (link private assembly, custom, partial, or location-based).
LOG: Attempting download of new URL file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files
/ WebAPI / d5634960 / b33de11c / AutomationMiddleware.Common.DLL.
LOG: Attempting download of new URL file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files / WebAPI / d5634960 / b33de11c / AutomationMiddleware.Common / AutomationMiddleware.Common. DLL.
LOG: Attempting download of new URL file: /// C: /inetpub/wwwroot/WebApi/bin/AutomationMiddleware.Common.DLL.
ERR: Failed to complete the installation of assembly (hr = 0x8007000B). He ended the search.
Stack trace:
[BadImageFormatException: Could not load file or assembly
'AutomationMiddleware.Common' or one of its dependencies. An attempt
was made to load a program with an incorrect format.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean
throwOnFileNotFound, Boolean forIntrospection, Boolean
suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName
assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean
throwOnFileNotFound, Boolean forIntrospection, Boolean
suppressSecurityChecks) +210
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,
Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr
pPrivHostBinder, Boolean forIntrospection) +242
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,
Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean
forIntrospection) +17 System.Reflection.Assembly.Load(String
assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String
assemblyName, Boolean starDirective) +122
[ConfigurationErrorsException: Could not load file or assembly
'AutomationMiddleware.Common' 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) +12495956
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
+499 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +131 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection
compConfig) +331
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String
preStartInitListPath, Boolean& isRefAssemblyLoaded) +148
System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager
appManager, IApplicationHost appHost, IConfigMapPathFactory
configMapPathFactory, HostingEnvironmentParameters hostingParameters,
PolicyLevel policyLevel, Exception appDomainCreationException) +1151
[HttpException (0x80004005): Could not load file or assembly
'AutomationMiddleware.Common' or one of its dependencies. An attempt
was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12617668
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
+159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +12457285
Microsoft .NET Framework:4.0.30319; Versión ASP.NET:4.0.30319.34237
我编译了x86架构的所有dll,同样的错误。使用任何 CPU 和相同的错误。并且使用 x64 和相同的错误。
AutomationMiddleware.Common
是我开发的一个程序集。所有程序集都是我的,除了 nuget 程序集(Entity Framework、Json.net 等)。
有什么想法吗?
嗯,看来这里有一个很奇怪的错误:
您是否搜索了您收到的错误代码?
This problem may occur if a file that the Windows Product Activation
(WPA) requires is damaged or missing. This behavior occurs if one or
both of the following conditions are true:
- A third-party backup utility or an antivirus program interferes with the installation of Windows XP.
- A file that WPA requires is manually modified.
可能需要更新一些外部依赖项?
我将其添加为社区 wiki 以帮助其他人解决此问题。
如果您遇到此问题,请检查此 SO 答案:。也许,它可以帮助你解决它。
我有一个 ASP.NET MVC 4 Web Api 应用程序,在 Windows 7 Professional 64 位和 IIS 7.0 上部署了 .NET Framework 4.0 和 C#。
当我 运行 应用 http://myHost/WebApi 时,我得到这个:
Can not load file or assembly 'AutomationMiddleware.Common' or one of its dependencies. An attempt was made to load a program with an incorrect format. Description: An unhandled exception when running the current web request. 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 'AutomationMiddleware.Common' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Source code error:
Has generated an uncontrolled 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.
Trail to load the assembly: The following information can be helpful to determine why no assembly 'AutomationMiddleware.Common' was loaded.The administrator assemblies are loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll Running under executable file c:\windows\system32\inetsrv\w3wp.exe --- Register of detailed errors.
=== Status information prior link ===
LOG: DisplayName = AutomationMiddleware.Common
(Partial)
AVS: partial link information for an assembly is provided:
AVS: Assembly Name:. AutomationMiddleware.Common | Domain Id: 2
AVS: A partial bond occurs when only provides part of the display name of the assembly.
AVS: This may lead to an incorrect load linker assembly.
AVS: It is recommended to provide a textual identity completely specified for assembly,
AVS: consisting of simple name, version, culture, and public key token.
AVS: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this problem.
LOG: AppBase = file: /// C: / inetpub / wwwroot / WebAPI /
LOG: Initial privatePath = C: \ inetpub \ wwwroot \ WebAPI \ bin Assembly Call: (Unknown). ===
LOG: This link begins in the context of default load.
LOG: Using the configuration file of the application: C: \ inetpub \ wwwroot \ WebAPI \ web.config
LOG: Using host configuration file: C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ aspnet.config
LOG: Using machine configuration file in C: \ Windows \ Microsoft.NET \ Framework64 \ v4.0.30319 \ config \ machine.config.
LOG: The policy is not being applied to reference at this time (link private assembly, custom, partial, or location-based).
LOG: Attempting download of new URL file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files / WebAPI / d5634960 / b33de11c / AutomationMiddleware.Common.DLL.
LOG: Attempting download of new URL file: /// C: /Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files / WebAPI / d5634960 / b33de11c / AutomationMiddleware.Common / AutomationMiddleware.Common. DLL.
LOG: Attempting download of new URL file: /// C: /inetpub/wwwroot/WebApi/bin/AutomationMiddleware.Common.DLL.
ERR: Failed to complete the installation of assembly (hr = 0x8007000B). He ended the search.Stack trace:
[BadImageFormatException: Could not load file or assembly 'AutomationMiddleware.Common' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17 System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122[ConfigurationErrorsException: Could not load file or assembly 'AutomationMiddleware.Common' 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) +12495956
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +499 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +131 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +331
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +148
System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151[HttpException (0x80004005): Could not load file or assembly 'AutomationMiddleware.Common' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12617668 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12457285Microsoft .NET Framework:4.0.30319; Versión ASP.NET:4.0.30319.34237
我编译了x86架构的所有dll,同样的错误。使用任何 CPU 和相同的错误。并且使用 x64 和相同的错误。
AutomationMiddleware.Common
是我开发的一个程序集。所有程序集都是我的,除了 nuget 程序集(Entity Framework、Json.net 等)。
有什么想法吗?
嗯,看来这里有一个很奇怪的错误:
您是否搜索了您收到的错误代码?
This problem may occur if a file that the Windows Product Activation (WPA) requires is damaged or missing. This behavior occurs if one or both of the following conditions are true:
- A third-party backup utility or an antivirus program interferes with the installation of Windows XP.
- A file that WPA requires is manually modified.
可能需要更新一些外部依赖项?
我将其添加为社区 wiki 以帮助其他人解决此问题。
如果您遇到此问题,请检查此 SO 答案:。也许,它可以帮助你解决它。