.netvb.netembedded-resourcesatellite-assembly

Customizing resources after deployment


I am trying to develop a utility that will allow customization of strings after our product is deployed. Satellite assemblies seem to be a good way to go here. I have plenty of experience with using Microsoft.VisualBasic.VBCodeProvider and Microsoft.CSharp.CSharpCodeProvider as part of a process where code can be compiled and loaded at runtime. However, satellite assemblies don't seem to involve a full compile process. As I look around the web for information on building satellite assemblies, it seems that you need to skip the code compiling step and just use the link step (AL.exe) to link a compiled .resources file into a satellite DLL.

I've gotten as far as generating the compiled .resources files using System.Resources.ResourceWriter, but I'm now looking for an elegant way to invoke the functionality in AL.exe that will create a DLL from that. Sure I could simply invoke System.Diagnostics.Process.Start on AL.EXE, but that doesn't seem very elegant seeing as how .NET framework has built-in classes for building .resources files and for compiling VB.NET and C# source code.

At the very least I need a good way to get the path to an appropriate AL.EXE executable, but preferably there would simply be a .NET class that can accomplish the linking.


Solution

  • I would recommend that you simply leave it as a .resources file, as described in this article.

    Dim resourceMgr = ResourceManager.CreateFileBasedResourceManager(resourceName, resourcePath, Nothing)
    

    Since MSDN notes that this locks the file, preventing updating an ASP.NET site, you may also wish to make a copy of the resource directory before creating the resource manager. Depending on how and when you plan to update them, you may also wish to keep these resource files under the App_Data folder.