检查.NET依赖启动前 [英] Checking for .NET dependencies before launching

查看:189
本文介绍了检查.NET依赖启动前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的工作,喜欢分发给朋友要求微软提供的.dll文件和框架或几个应用程序。具体而言,XNA。我累了让邮件从他们回来说:坠毁的,而实际上,所有这一切发生的是,他们没有安装XNA(或.NET 3.5,或者别的什么)。但是,主要可以因为.exe文件加载到主甚至执行前没有赶上这些错误。

I have several apps that I work on and like to distribute to friends that require Microsoft Provided .dlls and or frameworks. Specifically, XNA. I'm tired of getting emails back from them saying "It crashed" when in reality, all that's happened is they don't have XNA (or .NET 3.5, or whatever) installed. However, Main can't catch these errors because the .exe loads them before main is even executed.

所以,我的问题是,我将如何去创建一个启动,可以检查像.NET 3.5,XNA等,并显示一个友好的错误消息(此应用程序需要XNA 3.0,在这里下载! ),而不是看起来像坠毁?

So, my question is, how would I go about creating a launcher that could check for things like .NET 3.5, XNA, etc. and display a nice error message ("This application requires XNA 3.0, download it here!") instead of looking like it crashed?

更新:我应该规定,我想这样做,不使用安装程序。我有一个锅炉板维克斯安装程序,可以让我检查相关性,但有时我只是想上传一个zip供人玩弄。

UPDATE: I should have specified that I want to do this without using an installer. I have a boiler plate WIX installer that allows me to check for dependencies, but sometimes I just want to upload a zip for people to play around with.

推荐答案

要做到这一点没有一个安装程序,您可能希望创建一个启动脚本,做多一点所说的真正的切入点进行任何依赖性后,检查锋线。

To do this without an installer, you might want to create a "launcher" script that does little more than call the "real" entry point after performing any dependency checks up front.

由于缺少依赖似乎是痛苦,你很常见的来源,它可能是最好写超出其方式发射的东西有没有依赖关系是不是已经在裸Windows安装,如一个 AutoIt脚本的打包为一个可执行文件。

Since missing dependencies appear to be a very common source of pain for you, it's probably advisable to write the launcher in something that goes out of its way to have no dependencies that aren't already on a bare Windows installation, such as an AutoIt script packaged as an executable.

Const $AppTitle = 'Whizzy Game'
Const $MB_ICONERROR = 16

If RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5', 'Install') <> 1 Then
    MsgBox($MB_ICONERROR, $AppTitle, 'The .NET Framework runtime v3.5 is required to run.')
    Exit 1
EndIf

If RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\XNA\Framework\v3.1', 'Installed') <> 1 Then
    MsgBox($MB_ICONERROR, $AppTitle, 'The XNA Framework runtime v3.1 is required to run.')
    Exit 1
EndIf

Exit RunWait('WhizzySoftware.WhizzyGame.EntryPoint.exe')

这篇关于检查.NET依赖启动前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆