如何解决“%1 不是有效的 Win32 应用程序”?

发布于 2024-07-06 05:14:49 字数 532 浏览 7 评论 0原文

环境:
Windows Server 2003 R2 企业版 64 位,SP2
.NET Framework 应该已安装(2.0 SP2、3.0 SP2、3.5 SP1)

我说“应该”是因为它们在“添加/删除程序”下列为已安装。 我不确定它是否安装正确,因为“ASP.NET”选项卡未添加到 IIS 中的任何站点。

在 IIS Web 服务扩展部分,我有“ASP.NET v2.0.50727”(允许)和“ASP.NET v2.0.50727(32 位)”(禁止)。

相关站点已启用脚本执行。

问题:

我创建了一个超级简单的 ASP.NET/C# 网站:带有标签 id="Label1" 的 Default.aspx,以及一个隐藏代码:Label1.text = "Hello World"; 我得到的错误是:

%1 不是有效的 Win32 应用程序。

Environment:
Windows Server 2003 R2 Enterprise 64bit, SP2
.NET framework is supposedly installed (2.0 SP2, 3.0 SP2, 3.5 SP1)

I say "supposedly" because they are listed as installed under Add/Remove programs. I'm not sure it's properly installed, because the "ASP.NET" tab isn't added to any of the sites in IIS.

In the IIS Web Service Extensions section, I have both "ASP.NET v2.0.50727" (Allowed), and "ASP.NET v2.0.50727 (32-bit)" (Prohibited).

The site in question has script-execute enabled.

Problem:

I created a super-simple ASP.NET/C# website: Default.aspx with a label id="Label1", and a code-behind with: Label1.text = "Hello World"; and the error I'm getting is:

%1 is not a valid Win32 application.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

淡淡绿茶香 2024-07-13 05:14:49

您是否尝试过

aspnet_regiis -i

从命令行运行:?

Have you tried running:

aspnet_regiis -i

from the command line?

药祭#氼 2024-07-13 05:14:49

另请检查您的应用程序池。 在64位环境中,您可能需要在高级设置中设置“启用32位应用程序”。

Also check your application pool. In a 64-bit environment, you may need to set "Enable 32-bit applications" in Advanced Settings.

内心激荡 2024-07-13 05:14:49

我遇到“%1 不是有效的 Win32 应用程序”。 错误消息,因为我的 PATH 环境变量也被搞乱了。 它包含来自 python 安装的垃圾:

%PYTHON_HOME%;
%PYTHON_HOME%\Scripts;

I had "%1 is not a valid Win32 application." error message because my PATH environment variable was messed up as well. It included this garbage from a python install:

%PYTHON_HOME%;
%PYTHON_HOME%\Scripts;
累赘 2024-07-13 05:14:49

我遇到“%1 不是有效的 Win32 应用程序”。 错误消息,因为我的 PATH 环境变量被搞乱了。 嗯,更具体地说,PATH 本身没有任何问题。 相反,我不小心创建了一个名为“C:\Program”的文件,而不是“C:\Program Files\”用于路径查找。
意外创建“C:\Program”是由于在命令行上为C:\Program Files\test.txt(不带引号)调用Notepad++的结果,因此Notepad++认为我正在尝试编辑一个名为“C: \Program”并为我创建了该文件。

I had "%1 is not a valid Win32 application." error message because my PATH environment variable was messed up. Well, more specifically, the PATH itself had nothing wrong with it. Instead, I had accidentally created a file named "C:\Program" that was used instead of "C:\Program Files\" for path lookup.
The accidental creation of "C:\Program" was a result of calling Notepad++ on the command line for C:\Program Files\test.txt (without quotation marks), so Notepad++ thought I was trying to edit a file called "C:\Program" and created the file for me.

我在 Windows Server 2008 64 位上的 IIS7 上也遇到了类似的错误。

融合日志在这里没有任何帮助,事实证明,在我的例子中,有一个第三方程序集引用了仅 32 位的程序集或本机 dll。 (非常准确)

要查找 64 位运行时正在加载哪个程序集:

  • 将 VS2008 调试器附加到与您的应用程序池匹配的 w3wp.exe 进程上,
  • 拦截所有异常(菜单“调试”/“异常”/“检查”)所有“公共语言运行时异常”)。
  • 确保您的应用程序已完全重新加载(例如,通过修改 web.config)。
  • 当引发 System.BadImageFormatException 异常时,请在堆栈跟踪查看器窗口中查找程序集名称。

请记住,放置在 bin 目录中的所有程序集都会被加载,无论它们在应用程序中的实际含义如何。

I had a similar error with IIS7 on Windows Server 2008 64 Bits.

The fusion log is not of any help here, and it turned out that in my case there was a third party assembly that was referencing a 32 Bits only assembly or native dll. (Xceed to be precise)

To find which assembly is being loaded by the 64 bits runtime :

  • Attach the VS2008 debugger on w3wp.exe process that matches your application pool
  • Intercept all exceptions (Menu Debug / Exceptions / check all "Common Language Runtime Exceptions").
  • Make sure your application is reloaded completely (by modifying the web.config, for instance).
  • When the System.BadImageFormatException exception is raised, look for a assembly name in the stack trace viewer window.

Remember that all assemblies placed in the bin directory are loaded, regardless of their actual implication in the application.

怼怹恏 2024-07-13 05:14:49

我遇到了这个问题。 我将 .EXE 部署到不支持 .NET 4.5 的 Windows 2003。 我用 .NET 4 重建了程序并且它有效。

I had this problem. I deployed an .EXE to a Windows 2003 that doesn't support .NET 4.5. I rebuilt the program with .NET 4 and it worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文