简体   繁体   English

安装没有 dot net framework 的 C# 应用程序

[英]Installation C# application without dot net framework

I have created a new application on C# 2010. After creating a Setup file I came to know that for installation purposes user must have a dot net framework.我在 C# 2010 上创建了一个新应用程序。创建安装文件后,我知道为了安装目的,用户必须有一个 dot net 框架。 Is there any way I can get rid of installing dot net framework on a user computer.有什么办法可以摆脱在用户计算机上安装 dot net framework 的麻烦。 Each time I try to install my application on the user computer it redirects to install the dot net framework.每次我尝试在用户计算机上安装我的应用程序时,它都会重定向以安装 dot net 框架。 Any suggestion?有什么建议吗?

Well that's a problem;嗯,这是一个问题; because of the design of .NET applications.因为 .NET 应用程序的设计。

Here's some references for you: Visual C#这里有一些参考资料: Visual C#

"C# (pronounced "C sharp") is a programming language that is designed for building a variety of applications that run on the .NET Framework." “C#(发音为“CSharp”)是一种编程语言,旨在构建在 .NET Framework 上运行的各种应用程序。” [first sentence] 【第一句】

Intro to C# and .NET C# 和 .NET 简介

C# 和 .NET

As the comments on the question attempt to imply, the .NET Framework is required in order to execute .NET applications.正如对问题的评论试图暗示的那样,需要.NET Framework 才能执行 .NET 应用程序。

You have two choices, really:你有两个选择,真的:

  1. Require that users have the .NET Framework installed.要求用户安装 .NET Framework。 This is the most common choice, for reasons that will become clear in a moment.这是最常见的选择,原因稍后会变得清楚。 It's not unheard-of to have such requirements.有这样的要求并非闻所未闻。 It's similar to requiring that a user have Windows installed in order to run your Windows application.这类似于要求用户安装 Windows 才能运行您的 Windows 应用程序。
  2. Distribute the .NET Framework with your application installer.使用您的应用程序安装程序分发 .NET Framework。 This is possible, but less often used because the .NET Framework is large compared to the average application.这是可能的,但不太常用,因为与普通应用程序相比,.NET Framework很大 However, if you must do this, then the option is at least available.但是,如果您必须这样做,那么该选项至少是可用的。 Some quick Googling brought me to this helpful blog post .一些快速的谷歌搜索让我看到了这篇有用的博客文章

This isn't possible.这是不可能的。 C# is built on the .NET framework, so any C# app requires that a version of .NET be available. C# 构建在 .NET 框架之上,因此任何 C# 应用程序都需要一个可用的 .NET 版本。 At http://en.wikipedia.org/wiki/.NET_Framework#History , you can see what .NET framework versions are available in various versions of Windows.http://en.wikipedia.org/wiki/.NET_Framework#History 上,您可以查看各种版本的 Windows 中可用的 .NET 框架版本。 The short story is that XP doesn't include anything, Vista includes 3.0, and Windows 7 includes 3.5.简而言之,XP 不包含任何内容,Vista 包含 3.0,Windows 7 包含 3.5。 If you build for one of these versions, then on those OSes, your users won't need to install anything extra.如果您为这些版本之一构建,那么在这些操作系统上,您的用户将不需要安装任何额外的东西。 Using the Client Profile instead of the full .NET can also help reduce or eliminate installs your users will need to do.使用客户端配置文件而不是完整的 .NET 还有助于减少或消除用户需要进行的安装。

Unfortunately No. Its not possible.不幸的是,不,这是不可能的。

To explain it simple terms.用简单的术语来解释它。

Suppose if you have written only 1 Line of code where you would have simply declared an int variable, who will tell OS that it should create a space in memory?假设您只编写了 1 行代码,您只需在其中声明一个int变量,谁会告诉操作系统它应该在内存中创建一个空间?

That framework does exactly that creates basic environment to run your app in a System.该框架确实创建了在系统中运行您的应用程序的基本环境。

OOPs says about Real-world modeling and Relationships, so let me give you one from it. OOPs 谈到了真实世界的建模和关系,所以让我给你一个。

Think yourself to be the C# app and Mother Nature/Environment(Greenry) to be .Net Environment.(.Net is called an Environment)认为自己是 C# 应用程序,而大自然/环境(绿色)是 .Net 环境。(.Net 被称为环境)

Can you survive without mother nature?没有大自然,你能活下去吗? From first second that you are in this world, you breathe.从你来到这个世界的第一秒起,你就在呼吸。 Who provides you that oxygen.谁为你提供氧气。 MOTHER NATURE大自然

While creating installation bundle you can add dot net frame work exe file as prerequisites, then while installing your application it can check whether the system having .net framework or not.在创建安装包时,您可以添加 dot net frame work exe 文件作为先决条件,然后在安装应用程序时它可以检查系统是否具有 .net framework。 if it is not installed it your application can install the frame work.如果没有安装它,您的应用程序可以安装框架。

When you are using managed languages to writing applications you agreed to use their vm, c# codes compiles to IL which needs dot net framework for executing.当您使用托管语言编写应用程序时,您同意使用他们的 vm,c# 代码编译为 IL,这需要 dot net 框架才能执行。

.net framework by default exists on windows 7,8,8.1 and 10 and I don't think that this is a challenge. .net 框架默认存在于 Windows 7、8、8.1 和 10 上,我不认为这是一个挑战。

but if you insist on it so there is a way by using Mono, just remove features that does not support in mono from your project.但是,如果您坚持这样做,那么有一种使用 Mono 的方法,只需从您的项目中删除 Mono 不支持的功能即可。

first install mono and cygwin, then copy your exe and mono.dll file to a folder, be sure that your file name is not long because in some cases bundling faild,now you can start bundling using mkbundle command.首先安装mono和cygwin,然后将你的exe和mono.dll文件复制到一个文件夹中,确保你的文件名不长,因为在某些情况下捆绑失败,现在你可以使用mkbundle命令开始捆绑。

after bundling finished you have a exe file that can run without .net framework捆绑完成后,您有一个可以在没有 .net 框架的情况下运行的 exe 文件

hope this help you希望这对你有帮助

我有同样的问题,希望应用程序使用现有的 dot net framework 版本 (4.6) 进行设置,因为应用程序设置需要 4.7.2 版本,PC 不满足要求

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM