在仅安装 .NET 2.0 的系统上运行为 .NET 3.5 构建的软件
为 .NET 3.5 编译的软件在仅安装 .NET 2.0 的系统上崩溃之前需要多长时间?
我正在开发的应用程序使用 WPF 并需要 .NET 3.5,但如果用户没有安装它,我想显示一个用户友好的对话框(而不是崩溃)。
是否有任何标准方法可以执行此操作,或者有相关的 Microsoft 官方文档吗?
编辑:在理想的情况下,我只需检查安装过程中是否满足任何 .NET 依赖项。由于某些应用程序没有安装程序,并且用户可能在安装应用程序后卸载 .NET,因此我发现下面的答案很有用。
How far along does software compiled for .NET 3.5 get before crashing on a system that only has .NET 2.0 installed?
The application I am developing uses WPF and requires .NET 3.5, but I would like to display a user-friendly dialog (rather than crashing) if the user does not have it installed.
Are there any standard ways to do this, or official Microsoft documentation on it?
EDIT: In an ideal world I'd just check that any .NET dependencies are satisfied during installation. Since some applications do not have installers and since users could potentially uninstall .NET after the application is installed, I find the answers below to be useful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
它(可能)不会崩溃,直到它尝试使用需要 3.5 的 dll。如果执行的应用程序可以在使用任何 3.5 特定 dll 之前检查版本,则可以显示 winform 对话框,应该没问题。最安全的选择是使 exe 成为 2.0 程序集,并将所有 3.5 内容放在针对 3.5 编译的单独 dll 中。您可以在 2.0 dll 加载任何 3.5 程序集之前对其进行检查。
It (probably) wont crash until it tries to use a dll that needs 3.5. If the executing app can check the version before using any 3.5 specific dlls, you can display a winform dialog and you should be ok. Your safest bet would be to make the exe be a 2.0 assembly and make all of your 3.5 stuff in a separate dll that is compiled against 3.5. You could do your check in the 2.0 dll before it loads any of your 3.5 assemblies.
.NET 3.5 使用 .NET 2.0 运行时,因此应用程序将完全正常启动(但是,当它尝试加载 3.5 程序集时将会失败)。您可以检查 Environment.Version 看看它是否是您正在运行的 .NET 3.5 并向用户呈现标准
MessageBox.Show
(如果没有)。.NET 3.5 uses .NET 2.0 runtime, so an app will start perfectly fine (however, it will fail when it will attempt to load 3.5 assemblies). You can check Environment.Version to see if it's .NET 3.5 you're running on and present user with standard
MessageBox.Show
if not.您是否考虑过使用 ClickOnce 部署?代理将检查并安装您指定的任何必备项目,包括 .Net。它还使得应用程序的升级变得相当轻松。
Have you considered using ClickOnce deployment? The agent will check for and install any prerequisite items you specify, including .Net. It also makes pushing upgrades of your application fairly painless.