切换导航
{{systemName}}
{{ info.Title }}
{{info.Title}}
{{ menu.Title }}
{{menu.Title}}
登录
|
退出
搜索
VS2019能调试,但VS2022 出现加载格式不正确问题
作者:ych
有些Web项目,用Vs2019调试没有问题,用Vs2022就出现格式不正确。 ``` “/”应用程序中的服务器错误。 未能加载文件或程序集“My.WebApp”或它的某一个依赖项。试图加载格式不正确的程序。 说明: 执行当前 Web 请求期间,出现未经处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.BadImageFormatException: 未能加载文件或程序集“My.WebApp”或它的某一个依赖项。试图加载格式不正确的程序。 源错误: 执行当前 Web 请求期间生成了未经处理的异常。可以使用下面的异常堆栈跟踪信息确定有关异常原因和发生位置的信息。 程序集加载跟踪: 下列信息有助于确定程序集“My.WebApp”未能加载的原因。 === 预绑定状态信息 === 日志: DisplayName = My.WebApp (Partial) 警告: 为程序集提供了部分绑定信息: 警告: 程序集名称: My.WebApp | 域 ID: 2 警告: 当仅提供程序集显示名称的一部分时,将发生部分绑定。 警告: 这可能导致联编程序加载错误的程序集。 警告: 建议为程序集提供完全指定的文字标识, 警告: 并由简单名称、版本、区域性和公钥标记组成。 警告: 有关此问题的详细信息和常见解决方案,请参见白皮书 http://go.microsoft.com/fwlink/?LinkId=109270。 日志: Appbase = file:///C:/code/Code/CodeCodeStandardVersion/NewCodeStand/WebClientStand/My.Framework/My.WebApp/ 日志: 初始 PrivatePath = C:\code\Code\CodeCodeStandardVersion\NewCodeStand\WebClientStand\My.Framework\My.WebApp\bin 调用程序集: (Unknown)。 日志: 此绑定从 default 加载上下文开始。 日志: 正在使用应用程序配置文件: C:\code\Code\CodeCodeStandardVersion\NewCodeStand\WebClientStand\My.Framework\My.WebApp\web.config 日志: 使用主机配置文件: C:\Users\My\Documents\IISExpress\config\aspnet.config 日志: 使用 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config 的计算机配置文件。 日志: 此时没有为引用应用策略(私有、自定义、分部或基于位置的程序集绑定)。 日志: 尝试下载新的 URL file:///C:/Users/My/AppData/Local/Temp/Temporary ASP.NET Files/vs/99654595/47d22a5f/My.WebApp.DLL。 日志: 尝试下载新的 URL file:///C:/Users/My/AppData/Local/Temp/Temporary ASP.NET Files/vs/99654595/47d22a5f/My.WebApp/My.WebApp.DLL。 日志: 尝试下载新的 URL file:///C:/code/Code/CodeCodeStandardVersion/NewCodeStand/WebClientStand/My.Framework/My.WebApp/bin/My.WebApp.DLL。 错误: 未能完成程序集的安装(hr = 0x8007000b)。探测终止。 堆栈跟踪: [BadImageFormatException: 未能加载文件或程序集“My.WebApp”或它的某一个依赖项。试图加载格式不正确的程序。] 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) +232 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +113 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +23 System.Reflection.Assembly.Load(String assemblyString) +35 System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +48 [ConfigurationErrorsException: 未能加载文件或程序集“My.WebApp”或它的某一个依赖项。试图加载格式不正确的程序。] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +767 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +256 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +58 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +287 System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies() +69 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +137 System.Web.Compilation.BuildManager.ExecutePreAppStart() +172 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +854 [HttpException (0x80004005): 未能加载文件或程序集“My.WebApp”或它的某一个依赖项。试图加载格式不正确的程序。] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +532 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +111 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +719 版本信息: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.8.9282.0 ``` 找了很久的原因,发现 VS 2022的项目和解决方案中多个一个选项:“对项目和网站使用IIS Express 64位版本”,把其改为x86版本。项目就能正确调试了。 
评论区
先去登录
版权所有:机遇屋在线 Copyright © 2021-2025 jiyuwu Co., Ltd.
鲁ICP备16042261号-1