472,793 Members | 2,267 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,793 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 2101
>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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.