Generating shared Assembly through .net code RRS feed

  • Question

  • Hi,


    My requirement is to generate a dll through one part of my application. The generated dll will be used in another part of the application. But the old dll should also exists with the newly generated dll. The name of both the dlls would be same, so I have to use a Shared assembly for using both the dlls.


    My question is, can we generate a dll and attach a strong name and then register it in GAC through code without stopping the application. So when the new dll is registered my application will start referencing the new dll. How can this be achieved?


    Thanks & Regards.


    Pawan Kirtikar

    Saturday, May 10, 2008 9:09 AM


  • Signing and GAC installation is not something you can do with the .NET framework, afaik.  You could simply use the Process class to run the sn.exe and gacutil.exe utilities to get the job done.  To get the path to these utilities, use System.Runtime. InteropServices.RuntimeEnvironment. GetRuntimeDirectory().  If this sounds distasteful, consider that this exactly the way that System.CodeDom. Compiler.CodeGenerator works.

    Beware that if the assembly names are the same, you'll have to use a different version number to get them to co-exist in the GAC.

    Saturday, May 10, 2008 2:02 PM