471,354 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 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 1291
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

9 posts views Thread by John Smith | last post: by
3 posts views Thread by Thomas Müller-Lynch | last post: by
6 posts views Thread by Tim Roberts | last post: by
6 posts views Thread by Stephany Young | last post: by
1 post views Thread by nelsonivan | last post: by
4 posts views Thread by csharpula csharp | last post: by
4 posts views Thread by =?Utf-8?B?Y2xhcmE=?= | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.