简体   繁体   English

理解程序集的问题,以及来自不同程序集的资源

[英]Problem in understanding assembly, and resources from a different assembly

The book is WPF Unleashed, and it tells that binary resources from a different assembly can be used as well, but what it doesn't explain is the concept of assembly and the need to pack resources in a different assembly.这本书是 WPF Unleashed,它告诉我们也可以使用来自不同程序集的二进制资源,但它没有解释程序集的概念以及将资源打包到不同程序集中的必要性。 So i put the question here.所以我把问题放在这里。

I tried to google it, but couldn't find the answer that allows me to comprehend what is an assembly in WPF, and how to create an assembly that just consist of resources using Visual Studio 2010?我试图用谷歌搜索它,但找不到可以让我理解什么是 WPF 中的程序集以及如何使用 Visual Studio 2010 创建仅包含资源的程序集的答案?

And second, what is the advantage of packing resources in a different assembly except that they can be updated without shipping a brand new assembly of the product.其次,将资源打包在不同的组件中的优势是什么,除了它们可以在不运送全新的产品组件的情况下进行更新。

Here's a starting point:这是一个起点:

wiki on .NET Assemblies .NET 程序集上的 wiki

An Assembly is similar to a C++ DLL, but it has some other characteristics, such as metadata which describes the classes that are available for use.程序集类似于 C++ DLL,但它具有一些其他特征,例如描述可供使用的类的元数据。

One advantage of packing resources in a different assembly is that it gives a single point of reference - if you need to reuse resources across an application (or many applications) that use multiple assemblies, then this is a good strategy to adopt.在不同的程序集中打包资源的一个优点是它提供了一个单一的参考点 - 如果您需要在使用多个程序集的应用程序(或多个应用程序)中重用资源,那么这是一个很好的策略。 This is particularly useful if those resources need to be localized.如果这些资源需要本地化,这将特别有用。

WPF does not define assemblies, the concept is defined across the .NET Framework. WPF 不定义程序集,该概念是在 .NET Framework 中定义的。

WPF assemblies are no different than any other .NET assembly in terms of structure and use. WPF 程序集在结构和使用方面与任何其他 .NET 程序集没有什么不同。 They are the fundamental unit of deployment of an application (web, windows, service, etc) and contain resources for the execution of a .NET application.它们是应用程序(Web、Windows、服务等)部署的基本单元,包含用于执行 .NET 应用程序的资源。

I'd take a look at the MSDN article on assemblies -- it's pretty straightforward.我会看一下关于程序集的MSDN 文章——它非常简单。

As for your second question, I'll repeat my comment here.关于你的第二个问题,我在这里重复一下。 You already answered your question about packing resources in a separate assembly -- you can redeploy that separate assembly without having to redeploy or rebuild your original product.您已经回答了关于在单独的程序集中打包资源的问题——您可以重新部署该单独的程序集,而无需重新部署或重建您的原始产品。 You gotta like that.你得喜欢那个。 Being able to drop in to your bin directory an assembly that has, say, a bunch of custom widgets that you want to display on your site and having your site automatically probe the bin directory and grab all of the resources that meet its criteria is wonderful.能够将一个程序集放入您的 bin 目录,该程序集具有一堆您想要在您的站点上显示的自定义小部件,并让您的站点自动探测 bin 目录并获取所有符合其标准的资源,这真是太棒了. I don't end up having to touch my main app -- just create a new project for my new resources, compile it to a separate assembly (DLL in this case) and just drop it in 'bin' and voila!我最终不必接触我的主应用程序——只需为我的新资源创建一个新项目,将其编译为单独的程序集(在本例中为 DLL),然后将其放入“bin”中,瞧! Awesome.惊人的。

Hope this helps.希望这可以帮助。

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

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