Reflection Doubt!

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

    Reflection Doubt!

    Hi All, I am using Reflection for invoking an assembly.I use the
    LoadFrom(string ) Method, have few doubts, will appreciate all your answers.

    1. Should the assembly resides in GAC or at my custom location? (Please tell
    me pros/cons)
    2. If multiple calls are made to the target assembly by a Multithreaded
    app..it should be fine? (tips to keep in mind)

    TIA


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: Reflection Doubt!

    Vai2000,

    See inline:
    [color=blue]
    > 1. Should the assembly resides in GAC or at my custom location? (Please
    > tell
    > me pros/cons)[/color]

    When you use LoadFrom, you will not be loading the assembly from the
    GAC. It will either be in the location specified by the path passed to
    LoadFrom, or it will not. If you want to check the GAC, then you will want
    to use the Load method on the Assembly class to load it (assuming that
    fusion will find it in the gac).

    Another thing. As of version 2.0, I believe .NET grants full trust to
    everything that is placed in the GAC (being that an administrator has to
    install it there). If you are creating a plug-in architecture, then I don't
    know that you want to require that it is installed in the GAC.
    [color=blue]
    > 2. If multiple calls are made to the target assembly by a Multithreaded
    > app..it should be fine? (tips to keep in mind)[/color]

    No, it will not be. Every type in the assembly has to be coded to
    handle calls from multiple threads.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m



    [color=blue]
    >
    > TIA
    >
    >[/color]


    Comment

    • Vai2000

      #3
      Re: Reflection Doubt!

      Thanks as always

      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
      message news:ulxng0D9FH A.500@TK2MSFTNG P15.phx.gbl...[color=blue]
      > Vai2000,
      >
      > See inline:
      >[color=green]
      > > 1. Should the assembly resides in GAC or at my custom location? (Please
      > > tell
      > > me pros/cons)[/color]
      >
      > When you use LoadFrom, you will not be loading the assembly from the
      > GAC. It will either be in the location specified by the path passed to
      > LoadFrom, or it will not. If you want to check the GAC, then you will[/color]
      want[color=blue]
      > to use the Load method on the Assembly class to load it (assuming that
      > fusion will find it in the gac).
      >
      > Another thing. As of version 2.0, I believe .NET grants full trust to
      > everything that is placed in the GAC (being that an administrator has to
      > install it there). If you are creating a plug-in architecture, then I[/color]
      don't[color=blue]
      > know that you want to require that it is installed in the GAC.
      >[color=green]
      > > 2. If multiple calls are made to the target assembly by a Multithreaded
      > > app..it should be fine? (tips to keep in mind)[/color]
      >
      > No, it will not be. Every type in the assembly has to be coded to
      > handle calls from multiple threads.
      >
      > Hope this helps.
      >
      >
      > --
      > - Nicholas Paldino [.NET/C# MVP]
      > - mvp@spam.guard. caspershouse.co m
      >
      >
      >
      >[color=green]
      > >
      > > TIA
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Peter Rilling

        #4
        Re: Reflection Doubt!

        Let me expand on the second point. Once an assembly is loaded, all the
        classes and such are handled the same as types that were loaded when your
        app started. That means that if you have classes that do not maintain
        state, then you should be fine (thread safe), otherwise you would need to
        ensure your stuff are synchronized.

        "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
        message news:ulxng0D9FH A.500@TK2MSFTNG P15.phx.gbl...[color=blue]
        > Vai2000,
        >
        > See inline:
        >[color=green]
        >> 1. Should the assembly resides in GAC or at my custom location? (Please
        >> tell
        >> me pros/cons)[/color]
        >
        > When you use LoadFrom, you will not be loading the assembly from the
        > GAC. It will either be in the location specified by the path passed to
        > LoadFrom, or it will not. If you want to check the GAC, then you will
        > want to use the Load method on the Assembly class to load it (assuming
        > that fusion will find it in the gac).
        >
        > Another thing. As of version 2.0, I believe .NET grants full trust to
        > everything that is placed in the GAC (being that an administrator has to
        > install it there). If you are creating a plug-in architecture, then I
        > don't know that you want to require that it is installed in the GAC.
        >[color=green]
        >> 2. If multiple calls are made to the target assembly by a Multithreaded
        >> app..it should be fine? (tips to keep in mind)[/color]
        >
        > No, it will not be. Every type in the assembly has to be coded to
        > handle calls from multiple threads.
        >
        > Hope this helps.
        >
        >
        > --
        > - Nicholas Paldino [.NET/C# MVP]
        > - mvp@spam.guard. caspershouse.co m
        >
        >
        >
        >[color=green]
        >>
        >> TIA
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Stefan

          #5
          Re: Reflection Doubt!

          Hi,

          Check out my article on Reflection, it might help you answer your
          question.



          Happy Coding,

          Stefan
          C# GURU


          "You always have to look beyond the horizon and can never be complacent
          -- God forbid we become complacent."

          Jozef Straus

          *** Sent via Developersdex http://www.developersdex.com ***

          Comment

          Working...