列出所有可用的.NET程序集 [英] List all available .NET assemblies

查看:141
本文介绍了列出所有可用的.NET程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是列出所有可用的.NET 2.0组件的最佳方法是什么?

What is the best way to list all available .NET 2.0 assemblies?

所需的列表的一个例子是一个MS Visual Studio中显示,当你添加引用...在.NET选项卡。

An example of the list needed is the one MS Visual Studio shows when you do 'Add Reference...' in the .NET tab.

我看过Visual Studio中使用它自己的目录配置和GAC另一个和.NET安装目录另一个。我如何能知道任何想法在哪里这个目录在一台电脑可移植的方式(另一台电脑可能已经安装在D窗口:驱动器为例)

I have read Visual studio uses its own directory configuration and the GAC another and .NET instalation another. Any ideas of how I can know where this directories are in a computer portable way (another computer might have windows installed in D: drive for example)?

从列出的信息,则必须能够Assembly.Loadxxxx()吧。

From the information listed it must be possible to Assembly.Loadxxxx() it.

请注意:它应该做编程,而不是使用G​​ACUTIL例如(除非它提供了一个C#API)。所有这一切的目的是让你明白需要得到这个信息来创建自定义动态脚本编辑器。

Note: It should be done programatically and not using gacutil for example (unless it provides a C# API). The objective of all this is to create a custom dynamic script editor so you understand the need to get to this information.

推荐答案

首先,有参考组件和组件在GAC之间的一个重要区别。要编译code,你需要一个参考组装。要运行code,你所需要的组件无论是在同一文件夹的副本作为您的.exe或在GAC中的程序集。

First of all, there's an important difference between reference assemblies and assemblies in the GAC. To compile code, you need a reference assembly. To run code, you need either a copy of the assembly in the same folder as your .exe or the assembly in the GAC.

通常情况下,当你安装一个.NET应用程序,它的安装程序会复制它采用GAC中的程序集。这些组件是的没有的可作为参考集,你不能找出什么文件夹它是存储,所以你不能告诉编译器的/参考命令行参数的适当的值。嗯,你可以找到,但微软试图使它尽可能的努力与外壳加载项。

Normally, when you install a .NET application, its installer will copy the assemblies it uses in the GAC. Those assemblies are not usable as reference assemblies, you can't find out in what folder it is stored so you can't tell the compiler the proper value of its /reference command line argument. Well, you can find out but Microsoft tried to make it as hard as possible with a shell add-in.

不同的东西,当你安装一个.NET应用程序,允许你使用它的组件在自己的程序发生。像.NET框架。它会尽组件的两个副本。其中云在GAC,其他进入一个知名的位置。对于.NET框架中,这些著名的位置是C:\ WINDOWS \ microsoft.net \和C:\ Program Files文件\引用程序集。后者的文件夹开始得到使用.NET 3.0以上。

Something different happens when you install a .NET application that allows you to use its assemblies in your own program. Like the .NET framework. It will make two copies of every assembly. One goes in the GAC, the other goes in a "well-known" location. For the .NET framework, these well-known locations are c:\windows\microsoft.net\ and c:\program files\reference assemblies. The latter folder started getting used by .NET 3.0 and up.

Visual Studio的添加引用对话框使用注册表项,列出了这些著名地点。有一对夫妇,但重要的是 HKLM \软件\微软\ .NETFramework \ AssemblyFolders

Visual Studio's Add Reference dialog uses a registry key that lists these well-known locations. There are a couple, but the important one is HKLM\Software\Microsoft\.NETFramework\AssemblyFolders.

长话短说:您可以使用该注册表项,以产生添加引用对话框产生一个相同的列表。但它不是100%可靠的,你可能会错过一些产品复制其他地方引用程序集。你不得不使用浏览选项卡VS将引用添加到这些。而搜索整个硬盘给自己找到它们。

Long story short: you could use that registry key to produce the same list that the Add Reference dialog produces. But it is not 100% reliable, you might miss reference assemblies that some product copied somewhere else. You'd have to use the Browse tab in VS to add references to those. And search the entire disk to find them yourself.

这篇关于列出所有可用的.NET程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆