C# 里怎么得到C:\windows\assembly底下的GAC文件的version?

cutftp 2007-12-17 11:07:57
MSDN上的用法:
Assembly myAssembly = Assembly.Load("mscorlib.dll");
AssemblyName gacInfo = myAssembly.GetName();
Version myVersion = gacInfo.Version;
System.Console.WriteLine(myAssembly.GetName());


这个Assembly.Load("mscorlib.dll") 我如果想load c:\windows\assembly文件夹底下的GAC文件,怎么取得?

老说找不到文件


...全文
910 9 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Macosx 2007-12-17
  • 打赏
  • 举报
回复
为啥我的机器上就好使咧
yuan731 2007-12-17
  • 打赏
  • 举报
回复
string strpath = @"c:\windows\assembly\GAC";
Assembly myAssembly = Assembly.Load(strpath);
cutftp 2007-12-17
  • 打赏
  • 举报
回复
怎么写全,能详细点吗?谢谢了
拉达曼迪斯II 2007-12-17
  • 打赏
  • 举报
回复
你得写全.
包括PublicKeyToken等信息。
luyuanzhiwindows 2007-12-17
  • 打赏
  • 举报
回复
up
cutftp 2007-12-17
  • 打赏
  • 举报
回复
已解决,结贴,谢谢各位
cutftp 2007-12-17
  • 打赏
  • 举报
回复
我看过了,GUI里是直接放在C:\WINDOWS\assembly
而用命令行的看C:\WINDOWS\assembly的话,只能看到 GAC,GAC32 ,GAC_MSIL,NativeImages1_v1.1.4322,NativeImages_v2.0.50727_32等几个文件夹,我把路径写到这里面也不行。
Macosx,你在你机器上是怎么写的呢?能否帖下代码?谢谢了
Macosx 2007-12-17
  • 打赏
  • 举报
回复
你在命令行下看看c:\windows\assembly\GAC的结构 和你在GUI里看到的不一样
cutftp 2007-12-17
  • 打赏
  • 举报
回复
为啥我这么写就不行呢?
Assembly myAssembly = Assembly.Load("c:\windows\assembly\GAC\xxx.dll");
AssemblyName gacInfo = myAssembly.GetName();
Version myVersion = gacInfo.Version;

老是提示我 :
Could not load file or assembly 'c:\\windows\\assembly\\GAC\\xxx.dll' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
提供各种语言的反编译引擎 Reflector is a class browser for .NET components. It allows browsing and searching the meta data, IL instructions, resources and XML documentation stored in a .NET assembly. Reflector was first released in October 2000 running on .NET Framework 1.0 Beta. LINQ and .NET Framework 3.5: Reflector supports query expressions and other concepts introduced in C# 3.5. To enable this feature select ".NET 3.5" under View, Options, Disassembler, Optimization. .NET Framework compatibility: Reflector runs on all versions of the .NET Framework using its own assembly loading infrastructure which does not rely on the Reflection API. For example, Reflector can load .NET Framework 2.0 assemblies without having the .NET Framework 2.0 installed. Assembly Lists:When launched for the first time, Reflector allows you to choose a default set of assemblies. The list of assemblies is then stored in the Reflector.cfg file and will be loaded next time you open the program. Reflector allows creating multiple assembly lists and switching between the lists using the File, Open List dialog. To choose a different set of default assemblies for the current assembly list you should remove all assemblies from the list (DEL) and invoke the Refresh command (F5). Assembly Cache:When resolving an assembly reference, Reflector will first search the local path next to the assembly holding the reference and then falls back to the cache directories defined in the Reflector.cfg file. Reflector does not search the Global Assembly Cache (GAC) unless you add "%SystemRoot%\Assembly" to the cache directories list. Assembly Versioning: By default, assembly version numbers are ignored when resolving type and member references. You can enable side-by-side versioning in the options dialog but it is suggested to avoid this if possible.

111,112

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧