none
Get Assembly Type without loading RRS feed

  • Question

  • I'll retype my question...
    Is it possible to load an assemblies information (like public types and it's methods, properties) without loading the assembly into the appdomain?
    The Assembly.Load method doesn't work because sometimes it doesn't find all references (somehow) the Assembly.LoadFrom always worked - but it loads the Assemblies into the appdomain.

    Any idea?

    Thanks in advance
    trust is a weakness, betrayal is the hidden blade
    Monday, February 22, 2010 7:49 AM

Answers

All replies

  • I managed loading the assembly in another AppDomain using the DoCallback method.

    Just for interest... is there any way to get an assemblies type information without loading the Assembly calling Load, LoadFile, LoadFrom?
    trust is a weakness, betrayal is the hidden blade
    • Marked as answer by NeoKenshinX Monday, February 22, 2010 10:04 AM
    Monday, February 22, 2010 10:04 AM
  • There is no such thing in .NET managed surface. You could use either native MetaData APIs, or some managed wrappers for it (e.g. CCI).

    -Karel
    • Marked as answer by eryang Tuesday, March 2, 2010 5:54 AM
    Monday, February 22, 2010 5:04 PM
    Moderator
  • Get the bytes of the assembly, then use Assembly.ReflectionOnlyLoadFrom.

    byte[] bytes = File.ReadAllBytes(@"C:\Users\billybob\Documents\Visual Studio 2008\Projects\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe");
    Assembly assm = Assembly.ReflectionOnlyLoad(bytes);

    This will load the data from the file into the AppDomain, but it will keep the actual file writable.

    Coding Light - Illuminated Ideas and Algorithms in Software
    Coding Light WikiLinkedInForumsBrowser
    Monday, February 22, 2010 5:08 PM
    Moderator
  • Get the bytes of the assembly, then use Assembly.ReflectionOnlyLoadFrom.

    byte[] bytes = File.ReadAllBytes(@"C:\Users\billybob\Documents\Visual Studio 2008\Projects\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe");
    Assembly assm = Assembly.ReflectionOnlyLoad(bytes);

    This will load the data from the file into the AppDomain, but it will keep the actual file writable.

    Coding Light - Illuminated Ideas and Algorithms in Software
    Coding Light WikiLinkedInForumsBrowser

    Yes this is the way to go, if you are not going to instantiate classes and so on, and only want to do reflection stuff this will work. Is that correct? do you only want to do reflection?

    Cap'n
    Tuesday, February 23, 2010 3:11 PM
  • Get the bytes of the assembly, then use Assembly.ReflectionOnlyLoadFrom.

    byte[] bytes = File.ReadAllBytes(@"C:\Users\billybob\Documents\Visual Studio 2008\Projects\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\WindowsFormsApplication1.exe");
    Assembly assm = Assembly.ReflectionOnlyLoad(bytes);

    This will load the data from the file into the AppDomain, but it will keep the actual file writable.

    Coding Light - Illuminated Ideas and Algorithms in Software
    Coding Light WikiLinkedInForumsBrowser

    Right My Friend,

    Assembly.ReflectionOnlyLoad() is ment for the your problem only 
    Wednesday, February 24, 2010 6:53 AM