Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Assembly.LoadXXX methods and GAC

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dilip - 19 Mar 2008 19:12 GMT
I have a situation at work that has me wondering if GAC is causing
more harm than good in my particular scenario.

Our application depends on a third party dll that is installed in the
GAC.  This assembly seems to change its build/revision portion of its
version numbers with every new iteration of the software.  If I were
to write an application that dynamically loads this assembly using
reflection, and calls its members, there is no way my application can
remain in sync with the third party software, right?  I mean, if I
write my application to load a certain version from the GAC using
Assembly.Load and then deploy it and our vendor promptly comes out
with a new version that does not have any significant changes to the
shared assembly but still bumps up the build/revision number, my
application will now stop working because it can't find the right
version, right?  Of course when my vendor installs the new software my
application will also be restarted to ensure that I don't make calls
on zombie objects.

I guess my point is Assembly.LoadWithPartialName would've greatly
helped me here.  I simply want to pull whatever version of this shared
assembly is present in the GAC.

Either I am missing something blindingly obvious or else I have run
into a legitimate corner case.

Which is it?
Alberto Poblacion - 19 Mar 2008 19:35 GMT
There is a way that you can redirect your application to use a different
version of the assembly without recompiling your application: Add a
configuration file. The configuration file should be named
yourapplication.exe.config and, among the various things that it can
contain, there is a node called <bindingRedirect oldVersion=...
newVersion=.../> that you can apply to one of the referenced assemblies. The
.Net configuration tool in Control Panel can generate this file, so you
don't need to know the exact structure of the xml that it contains.

However, the "right" way to do things would be for the vendor that provides
the assembly to deliver a Publisher Policy every time that they produce a
new version of the assembly. The Publisher Policy is installed to the GAC,
and it contains the Binding Redirect that instructs the .Net runtime to
redirect requests for previous versions into the new (compatible) version,
so that the users don't have to reconfigure all the possible programs in the
system that might be making use of the assembly in the GAC.

>I have a situation at work that has me wondering if GAC is causing
> more harm than good in my particular scenario.
[quoted text clipped - 22 lines]
>
> Which is it?
Dilip - 19 Mar 2008 20:08 GMT
PublisherPolicy seems to be the way to go.  Thanks Alberto!!  I did
know about redirects and publisher policies but for some reason the
latter slipped my mind.

Are you saying that if I end up having something like this in code:

Assembly.Load("someassembly,version=1.0.0.0......");

and the vendor deploys someassembly ver 1.1.0.0, the publisher policy
will ensure that all requests for 1.0.0.0 versions are redirected to
the new ones?

OK.  That seems nice.  What if he comes up with 1.3.0.0 later?  In
other words is there a way in the publisher policy to redirect a
*range* of older versions to the latest version installed by the
vendor?

On Mar 19, 1:35 pm, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.org> wrote:
> There is a way that you can redirect your application to use a different
> version of the assembly without recompiling your application: Add a
[quoted text clipped - 39 lines]
>
> > Which is it?
Alberto Poblacion - 20 Mar 2008 09:45 GMT
> PublisherPolicy seems to be the way to go.  Thanks Alberto!!  I did
> know about redirects and publisher policies but for some reason the
[quoted text clipped - 7 lines]
> will ensure that all requests for 1.0.0.0 versions are redirected to
> the new ones?

   I believe it should work, although I have only tried it out with
statically linked assemblies. If you need to debug the fusion process, you
can use the Fusion Log Viewer (FUSLOGVW,EXE), which will show you the
complete process of searching for an assembly, the places where the runtime
is looking for it, the policies that are aplied, and so on.

> OK.  That seems nice.  What if he comes up with 1.3.0.0 later?  In
> other words is there a way in the publisher policy to redirect a
> *range* of older versions to the latest version installed by the
> vendor?

   The BindingPolicy allows a range of versions such as 1.2.3.4-1.9.9.9 for
the RequestedVersion, but the NewVersion has to be a specific one, such as
2.0.1.2. So you can redirect a range of older versions to a new one, but you
can't specify thet the "new one" always be automatically the latest.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.