本文介绍了与ASP.net vNext中的非托管代码互操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于互操作与ASP.net vNext/Core CLR的非托管代码的故事(如果有)是什么?

What's the story going to be (if any) around interop with unmanaged code for ASP.net vNext / Core CLR?

似乎存在关键位(DllImport和朋友)以允许非托管代码互操作,但是在这种情况下诸如打包和部署之类的事情将如何工作? vNext/CoreFX中的基本构建工件似乎不再是程序集,而是NuGet程序包.因此,在那种情况下,我们如何使新的project.json系统正常工作,以便将我们P/Invoking的非托管dll也包含在生成的NuGet包中?

The key bits (DllImport and friends) appear to be present to allow for unmanaged code interop, but how would things such as packaging and deployment work in this context? The basic build artifact in vNext / CoreFX no longer appears to be an assembly, but a NuGet package. So in that case, how would we make the new project.json system work so that unmanaged dlls that we're P/Invoking into are also included in the resulting NuGet package?

还是我在谈论尚未考虑的场景(或更令人失望的是,不会发生)?

Or am I talking about scenarios that have not been considered yet (or more disappointingly, not going to happen)?

推荐答案

这个故事尚未完全充实,但是已经有一些示例.最终,我们(从事此工作的Microsoft团队)正在某些场景下工作,以使NuGet程序包能够更好地支持程序包中的本机内容.

The story is yet to be fully fleshed out, but there are already examples of how to do this. Ultimately we (the Microsoft teams working on this) are working on some scenarios to enable NuGet packages to better support native content in packages.

要查看此示例, Kestrel Web服务器具有一些自己的托管代码,此外还包括 libuv 放在其NuGet软件包中,以实现跨平台的高效异步IO实现.

To see one example of this, the Kestrel web server has some of its own managed code, plus it includes libuv in its NuGet package for an efficient async IO implementation that is cross-platform.

由于NuGet还没有内置的通用解决方案,因此Kestrel的构建脚本使用了,以将本机内容包含在NuGet程序包中.然后要加载libuv,有一个一些代码根据运行中的环境动态地找出要加载的本机libuv.

Because there isn't yet a built-in general solution in NuGet, the build scripts for Kestrel use some custom actions to include the native content in the NuGet package. Then to load libuv there's some code that dynamically figures out which native libuv to load based on the environment in which it is running.

所以,是的,虽然有点混乱,但确实有效,这在改善团队的优先级列表中绝对是重要的.

So, yeah, it's a bit messy, but it does work, and this is definitely high on the team's priority list to improve.

这篇关于与ASP.net vNext中的非托管代码互操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-31 08:02