473,405 Members | 2,262 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,405 software developers and data experts.

Binding / Reflection - Another Question

Ok,

I think this is my last one - in my app, the user can select via a dialog
box the dll's they want to load. I use a checkbox to track this (no worries
there), but, once a dll has been bound, how can i make sure that during the
session that a dll can't be bound twice? I'm assuming there's "protection"
w/i the reflection process to stop this, (if so, is there an exception that
is thrown? ), if not, what can i do to stop this from happening.

Doug
Dec 2 '05 #1
4 1363
Doug,

I assume you are talking .NET assemblies here. One .NET dll assembly can be
attached to a application domain only once. However assembly with the same
file name can be attached to the same domain more than once of its full name
(file name, version, culture and public key token) differ. In this case it
is considered to be different assembly. Unfortunately on the disk they
appear with same file name.

Assemblies with the same full name can be attached to a process more than
once if they are laoded in different AppDomains.

You shouid probably elaborate little bit on your question. What are your
worries exactly?

If you want to get notified when assembly gets loaded in the applcication
domain you can hook on the AppDomain.AssemblyLoad event.
--

Stoitcho Goutsev (100) [C# MVP]

"Doug Handler" <dk*******@yahoo.com> wrote in message
news:uY*************@TK2MSFTNGP15.phx.gbl...
Ok,

I think this is my last one - in my app, the user can select via a dialog
box the dll's they want to load. I use a checkbox to track this (no
worries there), but, once a dll has been bound, how can i make sure that
during the session that a dll can't be bound twice? I'm assuming there's
"protection" w/i the reflection process to stop this, (if so, is there an
exception that is thrown? ), if not, what can i do to stop this from
happening.

Doug

Dec 2 '05 #2
My only concern is if somehow an assembly that was suppose to be upgraded
doesn't get removed via the installation proces (or whatever) and the user
browses to find it and decides s/he wants to load it.

Basically, assume that the Contacts channel (say version 1.0.0 w/ diskname
of contacts.dll) is in the \Channels directory. The user decides to "load"
that one. All is fine. Then later they install a new version say (version
1.1.0) and the old version (1.0.0) does NOT get removed. The filenames are
the same (contacts.dll). Now the app is "hosting" 2 Contacts I want to be
sure that this does NOT happen.

Does this make sense? Also, yes, i'm speaking specifically about .net
assemblies.

If i listen for the AssemblyLoad event, how can i see if that assembly
(regardless of version) is loaded? If loaded, i really want to "unload" it,
but apparently that can't be done, but if i can at least stop loading in the
first place, i can at least work around that.

Doug

"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:OV**************@tk2msftngp13.phx.gbl...
Doug,

I assume you are talking .NET assemblies here. One .NET dll assembly can
be attached to a application domain only once. However assembly with the
same file name can be attached to the same domain more than once of its
full name (file name, version, culture and public key token) differ. In
this case it is considered to be different assembly. Unfortunately on the
disk they appear with same file name.

Assemblies with the same full name can be attached to a process more than
once if they are laoded in different AppDomains.

You shouid probably elaborate little bit on your question. What are your
worries exactly?

If you want to get notified when assembly gets loaded in the applcication
domain you can hook on the AppDomain.AssemblyLoad event.
--

Stoitcho Goutsev (100) [C# MVP]

"Doug Handler" <dk*******@yahoo.com> wrote in message
news:uY*************@TK2MSFTNGP15.phx.gbl...
Ok,

I think this is my last one - in my app, the user can select via a dialog
box the dll's they want to load. I use a checkbox to track this (no
worries there), but, once a dll has been bound, how can i make sure that
during the session that a dll can't be bound twice? I'm assuming there's
"protection" w/i the reflection process to stop this, (if so, is there an
exception that is thrown? ), if not, what can i do to stop this from
happening.

Doug


Dec 2 '05 #3
Doug,

AsselmblyLoad is firead after the fact and once assembly is loaded it cannot
be unloaded.

If you want to disocver just the the version of the assembly you don't need
to loaded. You can use the AssemblyName class. Look in MSDN for AssemblyName
class and more specifically for its GetAssemblyName static methods and
Version property.

..NET 2.0 supports loading assembly for reflection pruposes only, but again
once loaded it cannot be unloaded. Look at the following articles for more
info on this.
http://msdn2.microsoft.com/en-us/library/ms172331.aspx
http://blogs.msdn.com/junfeng/archiv...24/219691.aspx
--
HTH
Stoitcho Goutsev (100) [C# MVP]
"Doug Handler" <dk*******@yahoo.com> wrote in message
news:eq**************@TK2MSFTNGP11.phx.gbl...
My only concern is if somehow an assembly that was suppose to be upgraded
doesn't get removed via the installation proces (or whatever) and the user
browses to find it and decides s/he wants to load it.

Basically, assume that the Contacts channel (say version 1.0.0 w/ diskname
of contacts.dll) is in the \Channels directory. The user decides to
"load" that one. All is fine. Then later they install a new version say
(version 1.1.0) and the old version (1.0.0) does NOT get removed. The
filenames are the same (contacts.dll). Now the app is "hosting" 2
Contacts I want to be sure that this does NOT happen.

Does this make sense? Also, yes, i'm speaking specifically about .net
assemblies.

If i listen for the AssemblyLoad event, how can i see if that assembly
(regardless of version) is loaded? If loaded, i really want to "unload"
it, but apparently that can't be done, but if i can at least stop loading
in the first place, i can at least work around that.

Doug

"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:OV**************@tk2msftngp13.phx.gbl...
Doug,

I assume you are talking .NET assemblies here. One .NET dll assembly can
be attached to a application domain only once. However assembly with the
same file name can be attached to the same domain more than once of its
full name (file name, version, culture and public key token) differ. In
this case it is considered to be different assembly. Unfortunately on the
disk they appear with same file name.

Assemblies with the same full name can be attached to a process more than
once if they are laoded in different AppDomains.

You shouid probably elaborate little bit on your question. What are your
worries exactly?

If you want to get notified when assembly gets loaded in the applcication
domain you can hook on the AppDomain.AssemblyLoad event.
--

Stoitcho Goutsev (100) [C# MVP]

"Doug Handler" <dk*******@yahoo.com> wrote in message
news:uY*************@TK2MSFTNGP15.phx.gbl...
Ok,

I think this is my last one - in my app, the user can select via a
dialog box the dll's they want to load. I use a checkbox to track this
(no worries there), but, once a dll has been bound, how can i make sure
that during the session that a dll can't be bound twice? I'm assuming
there's "protection" w/i the reflection process to stop this, (if so, is
there an exception that is thrown? ), if not, what can i do to stop this
from happening.

Doug



Dec 2 '05 #4
Stoitcho,

Thank you very much. I learned that i can't "unload" an assembly :( - it's
on my wish list for 3.0.

dh
"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:OJ**************@TK2MSFTNGP12.phx.gbl...
Doug,

AsselmblyLoad is firead after the fact and once assembly is loaded it
cannot be unloaded.

If you want to disocver just the the version of the assembly you don't
need to loaded. You can use the AssemblyName class. Look in MSDN for
AssemblyName class and more specifically for its GetAssemblyName static
methods and Version property.

.NET 2.0 supports loading assembly for reflection pruposes only, but again
once loaded it cannot be unloaded. Look at the following articles for more
info on this.
http://msdn2.microsoft.com/en-us/library/ms172331.aspx
http://blogs.msdn.com/junfeng/archiv...24/219691.aspx
--
HTH
Stoitcho Goutsev (100) [C# MVP]
"Doug Handler" <dk*******@yahoo.com> wrote in message
news:eq**************@TK2MSFTNGP11.phx.gbl...
My only concern is if somehow an assembly that was suppose to be upgraded
doesn't get removed via the installation proces (or whatever) and the
user browses to find it and decides s/he wants to load it.

Basically, assume that the Contacts channel (say version 1.0.0 w/
diskname of contacts.dll) is in the \Channels directory. The user
decides to "load" that one. All is fine. Then later they install a new
version say (version 1.1.0) and the old version (1.0.0) does NOT get
removed. The filenames are the same (contacts.dll). Now the app is
"hosting" 2 Contacts I want to be sure that this does NOT happen.

Does this make sense? Also, yes, i'm speaking specifically about .net
assemblies.

If i listen for the AssemblyLoad event, how can i see if that assembly
(regardless of version) is loaded? If loaded, i really want to "unload"
it, but apparently that can't be done, but if i can at least stop loading
in the first place, i can at least work around that.

Doug

"Stoitcho Goutsev (100) [C# MVP]" <10*@100.com> wrote in message
news:OV**************@tk2msftngp13.phx.gbl...
Doug,

I assume you are talking .NET assemblies here. One .NET dll assembly can
be attached to a application domain only once. However assembly with the
same file name can be attached to the same domain more than once of its
full name (file name, version, culture and public key token) differ. In
this case it is considered to be different assembly. Unfortunately on
the disk they appear with same file name.

Assemblies with the same full name can be attached to a process more
than once if they are laoded in different AppDomains.

You shouid probably elaborate little bit on your question. What are your
worries exactly?

If you want to get notified when assembly gets loaded in the
applcication domain you can hook on the AppDomain.AssemblyLoad event.
--

Stoitcho Goutsev (100) [C# MVP]

"Doug Handler" <dk*******@yahoo.com> wrote in message
news:uY*************@TK2MSFTNGP15.phx.gbl...
Ok,

I think this is my last one - in my app, the user can select via a
dialog box the dll's they want to load. I use a checkbox to track this
(no worries there), but, once a dll has been bound, how can i make sure
that during the session that a dll can't be bound twice? I'm assuming
there's "protection" w/i the reflection process to stop this, (if so,
is there an exception that is thrown? ), if not, what can i do to stop
this from happening.

Doug



Dec 3 '05 #5

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

Similar topics

5
by: Daniel Bass | last post by:
..Net is great for modulerising libraries, so that all you need do to access a DLL, is simply call Add Reference and wallah, it's as though the library were written in your project. But what...
9
by: John Smith | last post by:
Hey, I'm having a difficult time finding some good examples of late binding Outlook in C#. Anyone know of any good sites out there? I've googled and MSDN'ed, but have come up a bit empty. ...
3
by: Thomas Müller-Lynch | last post by:
How can I avoid late binding with the directive strict = tru My ASP .net-file looks like this <%@DEBUG=true TRACE=true Strict=false EXPLICIT=true% .. dim footerValues as Arra footerValues =...
13
by: Michael.Suarez | last post by:
Let's suppose I have an instance of MyClass, which has the properties MyText1 and MyText2, and sets the values of MyText1 and MyText2 to 'A' and 'B' in it's constructor. Let's also suppose I...
6
by: Tim Roberts | last post by:
I've been doing COM a long time, but I've just come across a behavior with late binding that surprises me. VB and VBS are not my normal milieux, so I'm hoping someone can point me to a document...
6
by: Stephany Young | last post by:
Using VS2005 and VB.NET and given a Windows Forms application with a single form (Form1) with 2 buttons (Button1 and Button2), I am attempting to instantiate an instance of Excel utilising late...
1
by: nelsonivan | last post by:
Hi, i'm trying to reference some objects using reflection and Late Binding accessing. The Object API to his methods it's easy to understand, and it's as "Object.Method" - aka....
4
by: csharpula csharp | last post by:
Hello, I would like to know how can I copy from BindingList<objto some other BindingList<obj>? I tried to pass one binding list to other via constractor but this is copying it by reference and I...
4
by: =?Utf-8?B?Y2xhcmE=?= | last post by:
Hi all, what is the difference between the late binding and reflection? clara -- thank you so much for your help
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: 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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.