Even easier single assembly modules

blog header image

During the last year, both Dan and Johan has made some great posts showing how to fit an entire module into a single .dll file. I’ve been very fascinated by this approach. It’s so clean and nice to just be able to drop a single assembly in the bin folder and magically, the plugin will appear in your EPiServer – everything embedded in 1 file – and running from it. The only thing bothering me is the amount of manual work (I’ve never been a fan of that) involved in making such an assembly (in spite of the good & helpful guides Dan & Johan have provided). So, since I want to use this approach to a couple of upcoming projects I decided to once and for all make a single assembly that contains a self registrating Virtual Path Provider to embedded resources. The code is directly from http://www.codeproject.com/KB/aspnet/ASP2UserControlLibrary.aspx and Dan’s implementation, with very little modifications.

With this assembly in your bin folder, you can add any other module that has embedded content and not worry about it – just reference the content like this:

~/App_Resource/DebugPlugin.dll/DebugPlugin.Debug.ascx

so, that would be [App Root]/App_Resource/[Assembly name]/[Namespace].[filename of embedded content]. You can embed pretty much anything – images, aspx, ascx, javascript, css files and so on.

If you’re in doubt as to what the resource is called in your assembly you can use Reflector to browse the assembly’s resources.

Remember to set the “Build Action” in Visual Studio to “Embedded Resource” for every piece that you want to access this way, and remove the “CodeFile” attribute from the registration of aspx and ascx files, not to break VS.

Deploy this assembly together with your plugins – if it’s already in the bin folder you are installing to, it can be skipped. One copy of it is all your need…

 

 

Recent posts