2012-03-22 7 views
1

[OK]をので、私は、このテンプレートなぜ剃刀はVisual Studioで動作し、exeでは外ではないのですか?

<h2 style="margin-bottom:2px;">Missing Files</h2> 
@if(@Model.m.Count > 0){ 
    <h4>Found @Model.m.Count missing file(s) from the pool folder</h4> 
    @foreach(var item in @Model.m) 
    { 
    <p class="alert alert-error">@item</p> 
    } 
}else{ 
    <h4 class="alert alert-success">Nothing missing from the pool folder.</h4> 
} 

<h2 style="margin-bottom:2px;">Wrong Sizes</h2> 
@if(@Model.w.Count > 0){ 
    <h4>Found @Model.w.Count file(s) with the wrong size.</h4> 
    @foreach(var item in @Model.m) 
    { 
    <p class="alert alert-error">@item</p> 
    } 
}else{ 
    <h4 class="alert alert-success">No files have the wrong size</h4> 
} 

を持っていると私はビルド時にコードが素晴らしい作品が、私は、デバッグディレクトリに移動して、生成された.exeファイルを実行しようとすると、私は

: Unable to compile template. Check the Errors list for details. 
    at RazorEngine.Compilation.DirectCompilerServiceBase.CompileType(TypeContext context) 
    at RazorEngine.Templating.TemplateService.CreateTemplate(String template, Type modelType) 
    at RazorEngine.Templating.TemplateService.GetTemplate(String template, Type modelType, String name) 
    at RazorEngine.Templating.TemplateService.Parse[T](String template, T model, String name) 
    at RazorEngine.Razor.Parse[T](String template, T model, String name) 
    at syncspec.Form1.btnBrowse_Click_1(Object sender, EventArgs e) in C:\Users\Matt\Documents\Visual Studio 2010\Projects\moodmedia\moodmedia\Form1.cs:line 93 
    at System.Windows.Forms.Control.OnClick(EventArgs e) 
    at System.Windows.Forms.Button.OnClick(EventArgs e) 
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) 
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) 
    at System.Windows.Forms.Control.WndProc(Message& m) 
    at System.Windows.Forms.ButtonBase.WndProc(Message& m) 
    at System.Windows.Forms.Button.WndProc(Message& m) 
    at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) 
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) 
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) 


************** Loaded Assemblies ************** 
mscorlib 
    Assembly Version: 4.0.0.0 
    Win32 Version: 4.0.30319.239 (RTMGDR.030319-2300) 
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll 
---------------------------------------- 
を取得

すべてのアイデアは、私が行方不明です何を、なぜそれがexeファイル

UPDATE

をクリックすることにより、Visual Studioの2010年ではなく、デバッグdeirectoryの外に動作しますFYI
using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 
using syncspec; 
using System.Net; 
using System.IO; 
using System.Xml; 
using System.Web.Razor; 
using RazorEngine; 
using RazorEngine.Templating; 


      string route = @"C:\testing\test.html"; 
      string template = System.IO.File.ReadAllText("template.html"); 

      FileStream fs = new FileStream(route, FileMode.Create); 
      using (StreamWriter outfile = new StreamWriter(fs)) 
      { 

       string result = Razor.Parse(template, new {m = missing, w = wrongSizes}); 
       outfile.Write(result); 

-

+3

が見えますか?どうして? – Yuck

+1

あなたの@Model宣言は一番上にありますか? –

+0

私の質問を宣言で更新する – Trace

答えて

1

が欠落してwrongSizesは両方のリストです私はかつてテンプレートメカニズムとしてかみそりをホストするためのWebを検索。明らかで難しいことではありません。私の知る最良の記事の一つは、以下の通りです:あなたはリサイズとかみそりビューエンジンを使用しようとしているよう

http://www.west-wind.com/weblog/posts/2010/Dec/27/Hosting-the-Razor-Engine-for-Templating-in-NonWeb-Applications

関連する問題