Note that there are some explanatory texts on larger screens.

plurals
  1. POSpark in a Console Application Targetting .NET 4.0
    primarykey
    data
    text
    <p>I was just wondering if anyone has successfully got Spark to work in a .NET 4.0 console application for compiling templates to HTML. Unfortunately I am getting the following error:</p> <pre><code>Unhandled Exception: Spark.Compiler.CompilerException: Dynamic view compilation failed. (0,0): error CS1703: An assembly with the same identity 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' has already been imported. Try removing one of the duplicate references. </code></pre> <p>However, when I target .NET 3.5 everything works fine, however I specifically wish to target 4.0. Has anyone solved this problem, some old threads on the Spark mailing list suggest I may just have to edit a line in the source, and recompile, but I hope this is a last resort.</p> <p>EDIT:</p> <pre><code> static void Main(string[] args) { if (args.Length &gt; 0) { var templatePath = Path.Combine(Environment.CurrentDirectory, args[0]); var templateName = Path.GetFileName(templatePath); var templateDirPath = Path.GetDirectoryName(templatePath); var viewFolder = new FileSystemViewFolder(templateDirPath); var sparkEngine = new SparkViewEngine { DefaultPageBaseType = typeof(SparkView).FullName, ViewFolder = viewFolder.Append(new SubViewFolder(viewFolder, "Shared")), }; var descriptor = new SparkViewDescriptor().AddTemplate(templateName); var view = sparkEngine.CreateInstance(descriptor) as SparkView; view.Model = args[1]; using (var writer = new StreamWriter(new FileStream(args[2], FileMode.Create), Encoding.UTF8)) { view.RenderView(writer); } } else { Console.WriteLine("&gt;&gt;&gt; error - missing arguments:\n\tSparkCompiler.exe [templatepath] [modelstring] [outputname]"); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload