public void Initialize() { string templateSource; var stream = typeof(Program).Assembly.GetManifestResourceStream("DescentGlovePie.Generator.Views." + TemplateName); if (stream == null) throw new ApplicationException("Missing assembly resource for Razor view " + TemplateName); using (stream) { templateSource = new StreamReader(stream).ReadToEnd(); } // This template uses iSynaptic.Commons, so let's make sure the runtime loads it templateSource = templateSource.ToMaybe().Value; var config = new TemplateServiceConfiguration { EncodedStringFactory = new RawStringFactory() }; _razor = RazorEngineService.Create(config); _razor.Compile(templateSource, TemplateName, typeof(MapInfo)); }