Nick: Thanks for the tip! I found MS KB article 317540 which is very interesting indeed.
Also thanks to John for the explanation about the EnterpriseServices.Internal class and its methods. My reason for wanting to put assemblies in the GAC myself though are because I'm writing an application that loads plug-ins. It's very likely however that a lot of versions of the same plug-in will exist and users will want to be able to use older versions of plug-ins along with new releases. One of the reasons I picked .NET as platform for this application is because it doesn't have problems with running multiple versions of components at the same time. The method I picked for solving this was to have an option in the application's GUI where you basically pick an assembly and the application inserts the file into the GAC, then puts the fully qualified name into a configuration file. This way I get around people replacing foo.dll (version 1) with foo.dll (version 2) and suddenly not having access to version 1 anymore. With everything securely in the GAC I won't have to worry about how people handle/name the DLLs. Now when the application starts I just read the config file and when needed I load the assembly using its fully qualified name directly from the GAC (most of the time that's where it'll come from anyway). It now seems that I either have to force people to distribute new versions of an assembly with an installer, have end-users fiddle with gacutil (which they won't have since they don't have the framework sdk installed) or use the Fusion API. Now I understand about what the KB article calls "assembly binding fragility" but it sure would have been nice to have some kind of SafelyInstallIntoGAC()-functionality :-) -Jeroen -----Original Message----- From: Nicholas Palmer [mailto:[EMAIL PROTECTED] Sent: dinsdag 30 september 2003 19:15 To: [EMAIL PROTECTED] Subject: Re: [ADVANCED-DOTNET] Adding assemblies to the GAC using the clas s library Jeroen, If you do a search for Fusion on MSDN or Google, you'll find some code that describes how to access the GAC using a very unknown API. I've taken the code and made a little admin program that I use to clean up my GAC, but the fusion library that I've downloaded can both add and delete entries from the GAC. If you can't find this in your search, let me know and I'll forward you the code. Nick. -----Original Message----- From: Jeroen van den Bos (DT) [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 30, 2003 5:03 AM To: [EMAIL PROTECTED] Subject: [ADVANCED-DOTNET] Adding assemblies to the GAC using the class library Hi all, In the MSDN docs (in article "Installing an Assembly into the Global Assembly Cache") I read that to install assemblies in the GAC you have to either create an installer 2.0 project or use gacutil. However, since .NET 1.1 there is a class called Publish in System.EnterpriseServices.Internal that has methods to do this as well (specifically, GacInstall() and GacRemove()). The original function of the class is to assist in publishing COM interfaces for COM+ apps, but after using those methods my conclusion is that it just works perfectly with any assembly. Now I'm wondering: is the MSDN article outdated or is there a reason not to use these methods that I'm not aware of? Thanks for any help, -Jeroen =================================== This list is hosted by DevelopMentor� http://www.develop.com NEW! ASP.NET courses you may be interested in: 2 Days of ASP.NET, 29 Sept 2003, in Redmond http://www.develop.com/courses/2daspdotnet Guerrilla ASP.NET, 13 Oct 2003, in Boston http://www.develop.com/courses/gaspdotnet View archives and manage your subscription(s) at http://discuss.develop.com
