473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

using Assembly.Load / Statics / Singelton-Objects

Hi

I can create types from dynamic loaaded assemblies (Assembly.Load)
with Assembly.GetTyp( <typename) - OK
I need a reference to the assembly (just Type.GetType() do not work )

now my question.

1) If i need different Types/Objects of the same Assembly in different
app.sections, should I use Assembly.Load() several times or shoud I
manage all dynamic loaded assemblies by myself (e.g. Hashtable) or is
there .net functionality to do this ?

2) How should I handle static / singelton-Objects in dynamic loaded
assemblies. Can other dyn-loaded types access them? What happens with
static / singelton-Objects loading the same Assembly again ?

Thank you
Peter
Dec 10 '07 #1
3 2134
>1) If i need different Types/Objects of the same Assembly in different
app.sections, should I use Assembly.Load() several times or shoud I
manage all dynamic loaded assemblies by myself (e.g. Hashtable) or is
there .net functionality to do this ?
If you Load the same assembly more than once, the exsting copy will be
used. So you'll not get multiple instances of the same assembly in the
same appdomain.

>2) How should I handle static / singelton-Objects in dynamic loaded
assemblies. Can other dyn-loaded types access them? What happens with
static / singelton-Objects loading the same Assembly again ?
Again, the existing copy is used. So they will share all statics and
singletons.

If the objects can be accessed from other types depend on how you
expose them.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dec 10 '07 #2
Peter wrote:
I can create types from dynamic loaaded assemblies (Assembly.Load)
with Assembly.GetTyp( <typename) - OK
I need a reference to the assembly (just Type.GetType() do not work )

now my question.

1) If i need different Types/Objects of the same Assembly in different
app.sections, should I use Assembly.Load() several times or shoud I
manage all dynamic loaded assemblies by myself (e.g. Hashtable) or is
there .net functionality to do this ?
I would consider it most nice to save the assembly reference, but you
will not be able to load the same assembly twice (in the same app
domain).
2) How should I handle static / singelton-Objects in dynamic loaded
assemblies. Can other dyn-loaded types access them?
If they can get a ref to it - yes, but ...
What happens with
static / singelton-Objects loading the same Assembly again ?
You can not. In same app domain.

If you load them in different app domains, then it is
different classes and you will have multiple instances.

Arne
Dec 10 '07 #3
On 11 Dez., 00:40, Arne Vajhøj <a...@vajhoej.dkwrote:
Peter wrote:
I can create types from dynamic loaaded assemblies (Assembly.Load)
with Assembly.GetTyp( <typename) - OK
I need a reference to the assembly (just Type.GetType() do not work )
now my question.
1) If i need different Types/Objects of the same Assembly in different
app.sections, should I use Assembly.Load() several times or shoud I
manage all dynamic loaded assemblies by myself (e.g. Hashtable) or is
there .net functionality to do this ?

I would consider it most nice to save the assembly reference, but you
will not be able to load the same assembly twice (in the same app
domain).
2) How should I handle static / singelton-Objects in dynamic loaded
assemblies. Can other dyn-loaded types access them?

If they can get a ref to it - yes, but ...
What happens with
static / singelton-Objects loading the same Assembly again ?

You can not. In same app domain.

If you load them in different app domains, then it is
different classes and you will have multiple instances.

Arne
Thank you.

So the "easygoing" solution is using Assembly.Load(..) whenever i
need the assembly.
( --1st time .net load the assembly, further calls .net give me the
reference to the loaded assembly -- in the same app domain.)
Peter



Dec 11 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Marcin Vorbrodt | last post by:
Hello dear fellows C++ coders! I saw a discussion here before about static memebr functions and doing singelton pattern. It was sugested that method like this was unsave (example from my code): ...
2
by: Foehammer | last post by:
Hello, I'm trying to load an assembly dynamically using an app domain. This is a proof-of-concept for a larger project, so please excuse the lame class names. TestLib is the dll where all the...
1
by: Martin Platt | last post by:
Guys! I've been playing about with some code trying to get the satellite assembly resource files to work. From what I understand you must have a fallback for a particular language, as well as...
3
by: TT (Tom Tempelaere) | last post by:
Hi there I am making a service project in C#, and I'm in the process of writing the installer. I made an installer class by using the "Add Installer" menu-item in the design window of the service,...
3
by: René P. | last post by:
Hello, i have a little application that search into a special folder to assemblys. Founded assembly would be load by Assembly.LoadFrom(). Is there a way to load only assemblys that are from my...
5
by: Jon | last post by:
For example, how do I prevent the following function from appearing in the assembly manifest? #pragma unmanaged void Fn() { int a = 1; } It is a large port, so transforming these global...
0
by: mathlec | last post by:
I have 2 WebApplication project (dummy and dummy2). The first is trying to load a UserControl compiled in the second. I've set up the application as follow: \_(Virtual directory) .:Modules:.
20
by: Aek | last post by:
We recently moved our large codebase over from VS7 to 8 and found that we now get access violations in atexit calls at shutdown when debugging the application in VS2005. This occurs in static...
3
by: DR | last post by:
I heard there is some trick to referencing statics in C# CLR stored procedure without having to mark the assembly as unsafe. Does anyone know this? This is usefull as the case of needing a little...
3
by: DR | last post by:
I heard there is some trick to referencing statics in VB.NET CLR stored procedure without having to mark the assembly as unsafe. Does anyone know this? This is usefull as the case of needing a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.