Problem with Assemblies and loading type using reflection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sacha

    #1

    Problem with Assemblies and loading type using reflection

    If I use Assembly.LoadFi le("name.dll") and then I want to create instace of
    class inside the assembly using reflection Type.GetType("c lass.name")
    doesn't work unless I do

    Assembly asm = Assembly.LoadFi le("name.dll") ;
    Type t = asm.GetType("cl ass.name");

    Is there a way to expose the new Assembly globally dynamically so I can use
    the standard Type.GetType()? I don't want to keep track of which assembly I
    loaded and where each class is store. In my code, I only know at runtime how
    many new assemblies I have to load


    Tks.


  • Bret Mulvey

    #2
    Re: Problem with Assemblies and loading type using reflection

    "Sacha" <sacha@severus. org> wrote in message
    news:#V7pIBQnDH A.976@tk2msftng p13.phx.gbl...[color=blue]
    > If I use Assembly.LoadFi le("name.dll") and then I want to create instace[/color]
    of[color=blue]
    > class inside the assembly using reflection Type.GetType("c lass.name")
    > doesn't work unless I do
    >
    > Assembly asm = Assembly.LoadFi le("name.dll") ;
    > Type t = asm.GetType("cl ass.name");
    >
    > Is there a way to expose the new Assembly globally dynamically so I can[/color]
    use[color=blue]
    > the standard Type.GetType()? I don't want to keep track of which assembly[/color]
    I[color=blue]
    > loaded and where each class is store. In my code, I only know at runtime[/color]
    how[color=blue]
    > many new assemblies I have to load
    >[/color]

    Type.GetType allows you to specify the assembly name, which you can
    incorporate at runtime. See the documentation for Type.GetType(st ring) on
    MSDN. Without specifying the assembly name, Type.GetType only looks in the
    calling assembly and in mscorlib.


    Comment

    Working...