locked
installing assembly with new version in GAC RRS feed

  • Question

  • Hi,

    I have an application that has got a shared dll which i'm installing in GAC. On a fresh device(i.e no previous version of my application installed) when i install and run my application, the assembly gets installed into GAC and my application can access it.
    But if after doing some changes to my shared dll and then with a newer version dll, i make a build and install it on the devcie after uninstalling the previous installation, the application is unable to find the dll and throws type load exception.

    I'm using .GAC file to install assembly into GAC. All my components(i.e exes, dll's) are in c#.net.

    Between the process of the uninstallation of previous build and installation of new build, if i run any managed app then the previous dll gets removed from GAC and then on installing and running my application new dll gets installed in GAC and application runs fine.

    But if i remove the previous installation and just after that install the new build and run the application, then it is not able to find the dll.

    I have read that if we use .GAC file to install the assembly into GAC then runtime installs the assemblies only when any managed app is run.
    So when i uninstall my previous build from the device, the .GAC file gets removed from windows folder. But the framework does not remove the dll until any managed app will run. And if before running any managed app, i install the new build and the same .GAC file again comes into the windows folder.Now when i run my application, that is a manged app, ideally the runtime should remove the previous assembly and install the new one.
    But looking at the situation it seems previous assembly is not getting removed and new assembly is also not getting installed.

    Is there something that i'm doing wrong in using GAC fro installing shared assemblies or something that i have mised?


    Yagyesh
    Tuesday, October 16, 2007 4:31 AM

Answers

  • There's no need to remove anything. Just copy new .GAC file over existing one and copy new version of the DLL where GAC file is pointing to. Next time you run any managed application, GAC would notice DLL presence and would GAC it if it's newer or delete it if it's older than the one already in GAC.

     

    Also keep in mind you have to keep strong name version of the assembly the same and bump up Win32 version. If you change strong name version it won't be the same assembly.

    Tuesday, October 16, 2007 6:55 AM

All replies

  • There's no need to remove anything. Just copy new .GAC file over existing one and copy new version of the DLL where GAC file is pointing to. Next time you run any managed application, GAC would notice DLL presence and would GAC it if it's newer or delete it if it's older than the one already in GAC.

     

    Also keep in mind you have to keep strong name version of the assembly the same and bump up Win32 version. If you change strong name version it won't be the same assembly.

    Tuesday, October 16, 2007 6:55 AM
  • Hi,

    The cab installation is doing what you just mentioned.
    When i uninstall the previous installation, .GAC will be removed from windows directory and the dll which GAC file was pointing to will also be removed.

    And after that if i install the new build, with changed version number of the dll and the same strong name, then .GAC file(which is exactly same as the previous one) will again be copied to windows directory and new dll will be copied to the location which .GAC file is pointing.

    So effectively it is happening exactly what u said. But still after new installation i'm always getting typelaod exception.
    If after uninstalling the application, i run any managed app than the previous versions of the dll from GAC is removed and than after installing the new build, the new version get installed in GAC and my application runs.

    I have also seen the exception message, in that it asks for the my newer version assembly and in GAC still the old assembly is there which is not removed or replaced by my new version.

    Any ideas?

    Thanks,
    Yagyesh


    Tuesday, October 16, 2007 7:44 AM
  • Is this problem so silly or it does not make any sense at all.?
    I expected a quick solution for this one but still no reply's from experts out there.
    Wednesday, October 17, 2007 5:21 AM