Reflection Doubt!

  • Thread starter Thread starter Vai2000
  • Start date Start date
V

Vai2000

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
 
Vai2000,

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

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.
2. If multiple calls are made to the target assembly by a Multithreaded
app..it should be fine? (tips to keep in mind)

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

Hope this helps.
 
Thanks as always

Nicholas Paldino said:
Vai2000,

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

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.
2. If multiple calls are made to the target assembly by a Multithreaded
app..it should be fine? (tips to keep in mind)

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]
- (e-mail address removed)



 
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 said:
Vai2000,

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

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.
2. If multiple calls are made to the target assembly by a Multithreaded
app..it should be fine? (tips to keep in mind)

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]
- (e-mail address removed)



 
Back
Top