jas*_*son 22
甚至没有尝试变得复杂,你可以掏空gacutil并捕获输出.例如,gacutil /l Microsoft.Practices.Unity给我:
Microsoft (R) .NET Global Assembly Cache Utility. Version 3.5.30729.1
Copyright (c) Microsoft Corporation. All rights reserved.
The Global Assembly Cache contains the following assemblies:
Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31
bf3856ad364e35, processorArchitecture=MSIL
Number of items = 1
Run Code Online (Sandbox Code Playgroud)
与gacutil /l Some.Nonexistant.Assembly:
Microsoft (R) .NET Global Assembly Cache Utility. Version 3.5.30729.1
Copyright (c) Microsoft Corporation. All rights reserved.
The Global Assembly Cache contains the following assemblies:
Number of items = 0
Run Code Online (Sandbox Code Playgroud)
这很容易实现和解析,并且不依赖于任何第三方实现.
从.NET,反射API - 如果它找不到程序集Assembly.Load(...)将抛出一个FileNotFoundException.API需要一个完全限定的程序集名称,因此我认为它必须在GAC中.我用它来测试SQL Server Compact Edition的存在:
Assembly foo = Assembly.Load("System.Data.SqlServerCe, Version=3.5.1.0, " +
"Culture=neutral, PublicKeyToken=89845dcd8080cc91");
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24345 次 |
| 最近记录: |