简体   繁体   English

.NET 框架? 还是 .NET 核心? 还是 .NET 标准? 或者以上都没有?

[英].NET Framework? Or .NET Core? Or .NET Standard? Or none of the above?

I have a few private libraries and programs written in .NET with the .NET Framework 4.7.2, most of them are WinForms, but a few are already written in WPF.我有一些使用 .NET Framework 4.7.2 用 .NET 编写的私有库和程序,其中大部分是 WinForms,但有一些已经用 WPF 编写。

I have a few base libraries used by all of the programs, then I usually have one library per program, using the base libraries and offering the business logic for this program and finally I have the program itself (executable) using the base libraries and the one busines logic library for this program to build the UI.我有一些所有程序都使用的基础库,然后我通常每个程序有一个库,使用基础库并为该程序提供业务逻辑,最后我拥有使用基础库和一个用于该程序构建 UI 的业务逻辑库。

Now I'd like to port one or two of these programs to run on Android as well and I'd like to use Xamarin for that.现在我想移植其中一两个程序以在 Android 上运行,并且我想为此使用 Xamarin。

After googling I understood that I can't use .NET Framework as the basis for that anymore, because .NET Framework is Windows only.谷歌搜索后,我明白我不能再使用 .NET Framework 作为它的基础,因为 .NET Framework 仅适用于 Windows。 But I didn't get what else to use?但是我没有得到其他可以使用的东西?


.NET Core seems to be one candidate, but if I understood it correctly, .NET Core only re-uses the same source code on different platforms, not the compiled files itself. .NET Core 似乎是一个候选,但如果我理解正确的话,.NET Core 只会在不同平台上重用相同的源代码,而不是编译文件本身。 And Microsoft is always only refering to Windows, Linux and OS X when talking about the cross-platform capabilities.微软在谈论跨平台功能时总是只提到 Windows、Linux 和 OS X。 What about Android?安卓呢? Is that covered by "Linux" in that context?在这种情况下,“Linux”是否涵盖了这一点?

Let's say, I have to port three of my base libraries, the busines logic library and the program.比方说,我必须移植我的三个基本库、业务逻辑库和程序。

I now have the program running on Android and on Windows desktop with the same base library and business logic library source code.我现在在 Android 和 Windows 桌面上运行程序,使用相同的基本库和业务逻辑库源代码。

All my other programs (not ported) use these three ported base libraries as well.我所有的其他程序(未移植)也使用这三个移植的基础库。

Now I'd like to change the code in one of my ported base libraries.现在我想更改我移植的基础库之一中的代码。 I now had to recompile any program using the changed base library, I can't just change the file and be done?我现在必须使用更改后的基础库重新编译任何程序,我不能只更改文件并完成?


.NET Standard seems to be another option. .NET Standard 似乎是另一种选择。 As far as I understood I can create one base library with .NET Standard and referencing that file from .NET Core or .NET Framework, is that right?据我所知,我可以使用 .NET Standard 创建一个基础库并从 .NET Core 或 .NET Framework 引用该文件,对吗? But can I reference this library from Android as well (using Xamarin)?但是我也可以从 Android 引用这个库吗(使用 Xamarin)?


To make a long question short... what do I have to do, to create one base library file (for instance one for accessing SQLite databases) and be able to reference this one base library file in Xamarin (for Android) and in Windows from other components using .NET Framework.把一个长问题说短......我必须做什么,创建一个基本库文件(例如一个用于访问 SQLite 数据库的文件),并能够在 Xamarin(适用于 Android)和 Windows 中引用这个基本库文件从使用 .NET Framework 的其他组件。

Is that even possible?这甚至可能吗?

There are a few different .NET implementations, and they each serve a different purpose.有几种不同的 .NET 实现,它们各自用于不同的目的。 The .NET framework was the original implementation, and only runs on Windows. .NET 框架是最初的实现,只能在 Windows 上运行。 Then, Xamarin Inc. created Mono .然后,Xamarin Inc. 创建了Mono It was built to be an open source version of the .NET framework.它被构建为 .NET 框架的开源版本。 Xamarin, for both Android and iOS, uses Mono as a .NET runtime because it has the smallest size and lightest footprint. Xamarin 适用于 Android 和 iOS,使用 Mono 作为 .NET 运行时,因为它具有最小的尺寸和最轻的占用空间。

Next, the open source movement comes around, and Microsoft creates .NET core, which serves as an open-source cross-platform implementation similar to Mono.接下来,开源运动来了,微软创建了 .NET core,它作为一个类似于 Mono 的开源跨平台实现。 By the way, .NET core binaries run cross-platform on any .NET core runtime.顺便说一下,.NET 核心二进制文件可以在任何 .NET 核心运行时跨平台运行。 Not the entire framework is implemented, and Microsoft creates the .NET Standard.没有实现整个框架,Microsoft 创建了 .NET Standard。 It is not an implementation, it is a specification for the binary format and APIs any .NET implementation must have.它不是一个实现,它是任何 .NET 实现必须具有的二进制格式和 API 的规范。 (Note: I'm not completely sure of the order they were actually created and standardized). (注意:我不完全确定它们实际创建和标准化的顺序)。

Almost all .NET libraries should be programmed to the .NET Standard, so you can use them on any of the three implementations.几乎所有 .NET 库都应该按照 .NET Standard 进行编程,因此您可以在这三种实现中的任何一种上使用它们。

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

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