我如何可以部署一个C#应用程序,如果用户没有安装.NET? [英] How can I deploy a C# application if users don't have .NET installed?

查看:314
本文介绍了我如何可以部署一个C#应用程序,如果用户没有安装.NET?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我想提供给我的用户一个C#程序,但问题是,它需要.NET框架4.0版。这是一个问题,因为它最近发布了pretty的(2010年4月),很多人可能没有它。更糟糕的是它需要一段时间才能下载和安装框架(大约10分钟)。

I have a C# program which I want to make available to my users, but the problem is that it requires .NET framework version 4.0. This is a problem because it was released pretty recently (April 2010) and a lot of people probably don't have it. To make matters worse it takes a while to download and install the framework (~10 minutes).

有什么办法,我可以安装我所需要的框架,只是一个组成部分?如果这是不可能的,我可以编译我的code到本机二进制特定系统

Is there any way I can install just a part of the framework I need? If that isn't possible can I compile my code down to a native binary for specific systems

如。 x86 32位,X86 64位,等等。

eg. x86 32-bit, x86 64-bit, etc.

我看了一家名为勺子 http://spoon.net/ 但是这看起来像它只是模拟一个服务器上的应用程序(有点像思杰)。我能做些什么来解决这个难题呢?

I've looked at a company called 'spoon' http://spoon.net/ but that looks like it just emulates apps on a server (sort of like citrix). What can I do to resolve this dilemma?

推荐答案

谁想要运行您的程序需要安装.NET Framework的相应版本。有没有办法来解决这个。老实说,这让我吃惊多久这个问题被问。你不能编译.NET code到任何类型的本机二进制的,你不能分发您所需要的框架仅部分。如果这一切你很重要,你应该在一开始选择了不同的开发平台。

Anyone who wants to run your program needs the appropriate version of the .NET Framework installed. There's no way to work around this. It honestly amazes me how often this question gets asked. You can't compile .NET code down to any kind of a "native binary", and you can't distribute only the portions of the framework that you need. If all of this was important to you, you should have chosen a different development platform in the beginning.

您唯一的选择是捆绑的.NET Framework以及应用程序的安装程序。使这个最容易对你的客户的方式是使用Visual Studio来创建一个安装项目,该项目将自动安装.NET FW如果他们没有它了,然后再安装应用程序,在一个单一的步骤。

Your only option is to bundle the .NET Framework along with your application's installer. The way to make this easiest on your customers is to use Visual Studio to create a setup project that will automatically install the .NET FW if they don't have it already, and then install your application, all in a single step process.

Visual Studio中内置了支持建立这样一个安装项目,也是最肮脏的工作是为您处理。文件 - >新建项目 - >其他项目类型 - >设置和放大器;部署 - > Visual Studio安装。然后,任意选取了安装项目或设置向导选项,然后按照说明进行操作。

Visual Studio has built-in support for creating such a setup project, and most of the dirty work is handled for you. File -> New Project -> Other Project Types -> Setup & Deployment -> Visual Studio Installer. Then, pick either the "Setup Project" or "Setup Wizard" option, and follow the instructions.

要记住,因为你已经对.NET 4.0开发的唯一的事情是,有两个版本的框架:完整版和客户端配置文件。客户端配置文件是一个尝试做的正是你提到并安装所使用的典型应用框架的唯一部分。你必须首先弄清楚这对你是一个部署选项。如果你的程序使用的类不是在客户端配置文件可用,您需要安装完整版。否则,你可以考虑安装客户端配置文件,这是默认的VS面向.NET 4.0 2010年选中目标框架设置为你的应用程序的所有新项目,根据项目属性。如果它没有设置为客户端配置文件已经,尝试改变它,看看它是否会进行编译。这是说,如果这一部署选项是提供给您最快捷的方式。但是,只有在左右两个框架之间大小的15%的差异,所以它是不是真的什么大不了的事,如果你必须部署的完整版本。

The only thing to keep in mind since you've developed for .NET 4.0 is that there are two versions of this framework: the full version and the "Client Profile". The Client Profile is an attempt to do exactly as you mention and install only the portions of the framework that are used by the typical application. You have to first figure out of this is a deployment option for you. If your program uses classes that are not available in the Client Profile, you need to install the full version. Otherwise, you can consider installing the Client Profile, which is the default for all new projects targeting .NET 4.0 in VS 2010. Check the "Target Framework" settings for your application, under the project Properties. If it's not set to Client Profile already, try changing it and see if it will compile. That's the quickest way to tell if this deployment option is available to you. But there's only about a 15% difference in size between the two frameworks, so it isn't really that big of a deal if you must deploy the full version.

无论哪种方式,安装项目将自动判断并捆绑了正确的版本为您的应用程序。绝对不要让用户单独下载并运行.NET安装程序。使用安装项目,并为他们这么做自动。如果你没有VS或不想使用一个提供,调查的替代品,如 Inno Setup的,这也支持部署和使用的应用程序安装.NET运行库。

Either way, the setup project will automatically determine and bundle the correct version for your app. Definitely don't make the user download and run the .NET installer separately. Use the setup project and do this for them automatically. If you don't have VS or don't want to use the one it provides, investigate alternatives, like Inno Setup, which also support deploying and installing the .NET runtime with an app.

这篇关于我如何可以部署一个C#应用程序,如果用户没有安装.NET?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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