Working with GAC from code
For some day ago I was working on testing an installer that did add some files to the GAC during installation. To ensure that the installer was working correct I needed some code that could check if some files did exist, add files and remove files from the GAC. I did need this for mainly 3 test cases; files already exist in GAC, files are installed correct and repair scenario when some files are deleted. I did find a good API wrapper on Junfena Zhana’s blog that did wrap the needed COM interactions. Based on this wrapper I did create a small class that did solve my problem.
Install assembly example
public static void InstallAssembly(string assemblyPath) { if (String.IsNullOrEmpty(assemblyPath)) { throw new ArgumentNullException("assemblyPath"); } AssemblyCache.InstallAssembly(assemblyPath, null, AssemblyCommitFlags.Force); } |