如何跨应用程序共享 Windows 8 WinRT Metro 风格库/组件
Metro 文档指出应用程序是自洽的(没有共享 DLL 等),所以我只是想知道如何通过创建可重用的组件/库来创建模块化的大型 Metro 应用程序。
考虑到 HTML5/JavaScript Metro 应用程序的情况,如果其中很多应用程序应包含相同的 CSS 和 JavaScript(考虑 jQuery、模板)或 WinJS 脚本,那么它看起来不太好……我期望存在某种形式的库/重用从一开始。
如今,HDD 空间肯定很便宜,但我认为应该建立版本化的库存储库,并且应该按需加载依赖项(WinRT 组件/库、JavaScript 库...等)(如果尚不可用)。这里不需要“轮子发明”,只需看看 Maven 和 Ivy 是如何做的......否则就会发现我们心爱的 jQuery 1.6.4 库部署在数十个(如果不是数百个)应用程序中,并且膨胀已准备就绪。 ..
The Metro documentation states that the applications are self-consistent (no shared DLL’s, etc), So I’m just wondering how you can create a modular, BIG Metro application by creating reusable components/libraries.
Considering the case for HTML5/JavaScript Metro apps, if a lot of them should contain the same CSS and JavaScript (consider jQuery, templates) or WinJS scripts then it doesn't look quite good … I expected some form of libraries/reuse to exist from the start.
The HDD space is definitely cheap nowadays but I think that a versioned library repository should be in place and the dependencies (WinRT components/libraries, JavaScript libraries...etc) should be loaded on demand (if not already available). No "wheel invention" here needed, just look how Maven and Ivy is doing it .... otherwise will find out that our beloved jQuery 1.6.4 library is deployed in tens (if not hundreds) of applications and the bloat is ready ...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
作为一般规则,每个 WinRT/Metro 样式应用程序只能访问 Windows 内置的或在其 appx 包中附带的 dll。没有工具可以传送集中引用的 dll。每个想要使用 dll/库的应用程序都需要一个附带的副本。
As a general rule, each WinRT/Metro style application can access only dlls that are built into Windows or are shipped in their appx package. There is no facility to ship centrally referenced dlls. Each application that wants to use a dll/library will need a copy that ships with it.
您可以共享库,只是不会使用 DLL 来实现。您可以轻松创建具有常用实用程序和函数的类库,然后在您的应用程序中引用/共享它。您还可以使用 C++ 并通过 WinRT 创建自己的共享函数。
You can share libraries, you just won't be doing it using DLLs. You can easily create a class library with common utilities and functions, then reference/share it in your application. You can also drop to C++ and create your own shared functions via WinRT.
正如您所指出的,没有任何类型的全局程序集缓存用于保存库/组件的单个实例并将其与任何需要它的应用程序共享。虽然 .NET 中的 GAC 很好,但我认为没有多少开发人员利用它。是否有许多一次性 .NET 应用程序共享保存在 GAC 中的组件程序集?我相信这个百分比不是很高,因此所有这些程序集都是重复的。对我来说,不花时间在 Metro GAC 上的决定似乎是有道理的。
如果他们确实构建了 Metro,则需要为其实现 3 个全局缓存。 .NET、C++ 和 JavaScript 各一个。似乎有道理。这听起来简直是一团糟。另外,缓存如何知道机器上没有应用程序再使用某个程序集并且可以将其删除?凌乱...
这是一个相当复杂的主题,并且没有真正的简短答案解决方案。不管争论如何,他们可能正在研究这个问题的解决方案,只是还没有在 Windows 开发者预览版中发布它。需要更多时间来了解该平台如何发展以接近发布。
As you point out there isn't any kind of Global Assembly Cache for saving a single instance of a library/component and sharing it with any app that needs it. While the GAC in .NET is nice, I don't think very many developers take advantage of it. Hoe many one off .NET apps share component assemblies that are saved in the GAC? I believe the percentage isn't very high, consequentially all those assemblies are duplicated. The decision to not spend time on a Metro GAC seems warranted to me.
They would need to implement 3 global caches for Metro if they did build it. One for each .NET, C++ and JavaScript. It seems to make sense. This just sounds like a mess. Plus, how does the cache know that no apps on the machine use a certain assembly anymore and it can be deleted? Messy...
This is a fairly complex topic, and doesn't really have a short answer solution. No matter the debate, they may be working on a solution to this and just haven't released it in the Windows Developer Preview. More time is needed to see how the platform evolves closer to release.
WinRT 允许 Metro 应用程序“依赖”框架对象。该对象可以包含多个应用程序可能使用的所有共享 DLL 等。
WinRT allows a Metro application to take a 'dependency' on a Framework object. That object can contain all the shared DLLs, etc. that multiple applications may use.