如何使 .Net 4.0 Exe 要求用户在运行此 exe 之前下载 .Net 4.0 框架/可再发行组件?
我认为最新的 Matlab 会自动执行此操作。我在干净的 Win XP 虚拟机上测试了以下 exe:
namespace DotNetTest
{
using System.Windows.Forms;
class Program
{
static void Main(string[] args)
{
MessageBox.Show("Howdy!");
}
}
}
当我在安装了所有这些的计算机上运行它时,它确实显示消息框和窗口。当我在干净的虚拟机上运行它时,我收到此错误:
Title: DotNetTest.exe - Application Error
Icon: Error
Buttons: {OK}
Message Body: The application failed to initialize properly (0xc0000135). Click on OK to terminate the application.
我对 MSFT 天才的期望会更好。为什么每个 .Net exe 不能包含一点点开销,并让它的第一个字节来检测 .Net 是否安装并呈现更好的消息。
我可以翻转某种设置来解决这个问题吗?所有设置都是我创建新项目时VS2010提供的默认设置。
谢谢。
I thought that latest Matlab does this automatically. I have tested the following exe on a clean Win XP VM:
namespace DotNetTest
{
using System.Windows.Forms;
class Program
{
static void Main(string[] args)
{
MessageBox.Show("Howdy!");
}
}
}
When I run it on a computer which has all these installed, it does show the message box and a window. When I run it on a clean VM, I get this error:
Title: DotNetTest.exe - Application Error
Icon: Error
Buttons: {OK}
Message Body: The application failed to initialize properly (0xc0000135). Click on OK to terminate the application.
I would expect better from MSFT geniuses. Why cannot every .Net exe contain a tiny bit of overhead and have the very first bytes of it do the work of detecting if .Net is installed and presenting a better message.
Is there some sort of setting that I can flip to fix this? All of the settings were default ones provided by VS2010 when I created a new project.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这就是您使用安装程序的目的。在 .net 中,这很简单,您只需“发布”您的项目,然后您将获得一个安装程序,使 .net 已安装等。应用程序本身永远不必担心这一点。
This is what you use an installer for. In .net this is simple, you just "publish" your project and you get an installer that makes shure that .net is installed and such. The application itself should never have to worry about that.
正如亚历山大所说,您确实应该使用安装程序来实现此目的。如果这是不可能的,您必须先编写一个非托管 exe 来运行,然后启动 .net exe 或告诉用户下载框架,具体取决于框架是否已安装。
As Alexandr says, you should really use the installer for this. If that's not possible, you'd have to write an unmanaged exe to run first and then either start the .net exe or tell the user to download the framework depending on if it's already installed.