This project is read-only.

Problem compiling using RazorEngine in site

Sep 27, 2011 at 12:01 PM

Hello guys,

i had a problem compiling a razor template (the content doesnt matter) in a mvc project. it gave an error during compilation saying that the same assembly had been added already to the list of references sent to the codedom.

i traced the problem to the CompilerResults Compile(TypeContext context) method in DirectCompilerServiceBase where it takes all the loaded assemblies and add them as references. i modified the following to get it working, [there are probably better ways to do this]

Dictionary<string, string> references = new Dictionary<string, string>();

var assemblies = CompilerServices
    .Where(a => !a.IsDynamic)
    .Select(a => a.Location)

foreach (var a in assemblies)
    references[Path.GetFileName(a)] = a;


i hope you can add something similar to the main code base :)