How to load assembly from GAC?

I am trying to use Assembly.Load () to load an assembly located in the GAC. For example, let's say I want to list all the types that exist in PresentationCore.dll , how can I immerse PresentationCore.dll ?

When I try this:

Assembly a = Assembly.Load("PresentationCore.dll");

I get a FileNotFoundException . Another answer to SO suggested that I used Assembly.LoadFrom () for this - I hesitate to do this because Assembly.LoadFrom () is deprecated according to Visual Studio 2008 - plus it doesn't seem to actually work.

Any ideas?

+3
source share
5 answers

GAC, .

, mscorlib.dll, - :

Assembly a = Assembly.Load
    ("mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");

- Reflector :

http://i42.tinypic.com/2m30ocn.png

+11

Assembly.Load(), DLL. DLL Reflector, . PresentationCore.dll - PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.

+5

Runtime Locates Assemblies MSDN , , CLR .

Fusion Log Viewer . , Fusion, , .

+3

- , :

string regStringMath = typeof(System.Math).Assembly;
Assembly assMath = Assembly.Load("System.Math", regStringMath);

string regStringPres = typeof(PresentationCore).Assembly;
Assembly assPres = Assembly.Load("PresentationCore", regStringPres);

, .

+1
0

Source: https://habr.com/ru/post/1710515/


All Articles