通用运行时?

发布于 2024-07-11 11:46:32 字数 189 浏览 8 评论 0原文

有一点我不太清楚,我知道 C# 和 VB.NET 之间存在差异(主要是指针的使用),但为什么如果两者都有通用 CLR,XNA(例如)是否只能与 C# 一起使用,而不能与 VB 一起使用.NET,或者 Visual Studio 的插件是针对 C# 而不是 VB.Net,事实上语言扩展在这两种语言中都有效。

抱歉,如果这是一个明显的问题,我想我会问

Something I'm not to clear about, I understand there are differences between C# and VB.NET (mainly in the use of pointers) but why if both have a Common CLR, does XNA (for example) only work with C# and not VB.NET, or is it that the add ins to visual studio have been aimed at C# rather than VB.Net, and infact the language extensions work in both

Sorry if it's a obvious question, thought I'd ask

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

极度宠爱 2024-07-18 11:46:32

它是定义语言支持的工具集。 例如,XNA 只是使用 C# 完成所有工作,并且只提供对其的支持。 您仍然可以在 VB.NET 中编写应用程序并从命令行手动编译它。 只要您的应用程序没有编译为任何非法 IL(XNA 不支持的操作码),它仍然会运行。 主要问题是资源 - 他们没有人力来对所有语言进行全面开发和测试,因此他们选择了一种。

It's the tool set that defines the language support. XNA, for example, simply did all their work with C# and only shipped support for it. You could still write an app in VB.NET and manually compile it from the command line. As long as your app didn't compile down to any illegal IL (opcodes that XNA doesn't support) it will still run. The primary issue is resources - they don't have the manpower to do full development and testing of all of the languages, so they picked one.

二智少女猫性小仙女 2024-07-18 11:46:32

CLR 已被移植到各种平台,但并非所有平台都是相同的。 例如,XBox 360 CLR 没有 Reflection.Emit 甚至没有完整 CLR 执行的所有 IL 操作。 因此,不同的编译器可能会发出在完整 CLR 上合法但在 Compact CLR 上非法的 IL 代码。

另一个问题是类库的可用性。 完整的 BCL 包括 Microsoft.VisualBasic 命名空间,它是由 VB.NET 编译器自动引用。 其中包含 VB6 兼容性 函数,< a href="http://msdn.microsoft.com/en-us/library/microsoft.visualbasic.myservices.aspx" rel="nofollow noreferrer">我的命名空间 功能,以及一些编译器辅助函数,通常称为 VB。 NET 运行时。

每当移植 CLR 时,某些程序集就会被移植,而其他程序集则不会。 对于 Xbox,Microsoft.VisualBasic 未移植。 这意味着您无法引用该命名空间中的任何内容。 虽然不引用兼容性或“我的命名空间”相当容易,但可以将编译器服务插入到已编译的 IL 中,而无需显式调用它们。

在 VB.NET 8 中,您可以传递 未记录且不受支持的 -novbruntimeref 开关vbc.exe 以防止其引用 Microsoft.VisualBasic.dll。 不幸的是,这有时会导致奇怪的编译器错误。 在 VB.NET 9 中,它已成为记录和支持并重命名为 /vbruntime。

第三种情况是插件和 Visual Studio 支持。 这取决于各个软件包,是否支持每种语言的模板、代码生成等。 我相信一些第 3 方已经发布了 XNA 的 VB.NET 模板,尽管 它是未得到官方支持

我想,底线是技术问题(CLR 端口、BCL 可用性、编译器 IL 输出)和支持(测试、资助和其他语言的插件)的混合体。

The CLR has been ported to various platforms, not all of which are equal. The XBox 360 CLR, for instance, does not have Reflection.Emit or even all of the IL ops that the full CLR does. Hence, a different compiler may emit IL codes that are legal on the full CLR, but illegal on the Compact CLR.

The other issue is the availability of class libraries. The full BCL includes the Microsoft.VisualBasic namespace, which is automatically referenced by the VB.NET compiler. This contains VB6 compatibility functions, the My namespace features, as well as some compiler helper functions, and is commonly referred to as the VB.NET runtime.

Whenever the CLR is ported, certain assemblies are ported - and others are not. For the XBox, Microsoft.VisualBasic was not ported. This means that you cannot reference anything from that namespace. While it's fairly easy to not reference the compatibility or My namespaces, the compiler services can be inserted into the compiled IL without you explicitly calling them.

In VB.NET 8, you could pass an undocumented and unsupported -novbruntimeref switch to vbc.exe to keep it from referencing Microsoft.VisualBasic.dll. Unfortunately, this would sometimes cause odd compiler errors. In VB.NET 9, it's become documented and supported and renamed to /vbruntime.

The 3rd case is addins and Visual Studio support. This is up to the individual packages, as to whether they support templates, code gen, etc. for each language. I believe some 3rd parties have released VB.NET templates for XNA, though it's not officially supported.

Bottom line, I guess, is that it's a mix of technical concerns (CLR ports, BCL availability, compiler IL output) and support (testing, funding, and addins for other languages).

眼眸里的那抹悲凉 2024-07-18 11:46:32

从所有方面来看,VB.NET 和 C# 在 CLR 方面是等效的 99.9999。 但有一些细微的差异可能会让您感到困扰。 另外,我记得在一些微软博客上读到,CLR 可以做的一些事情还不能通过 VB.NET 或 C# 编程,而必须通过 IL 来完成。 确实很有趣。

From all accounts VB.NET and C# are 99.9999 equivalent when it comes to the CLR. But there are some slight differences that may bite you. In addtion I remember reading on some microsoft blog that there are some things the CLR can do that are not (yet) programmable by either VB.NET or C# and have to be done by IL. Interesting indeed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文