1
好了,所以我有這個模板爲什麼剃鬚刀在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>
}
,當我建立了代碼工作很好,但是當我在調試目錄中去嘗試運行時生成我得到
: 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文件
任何想法,我缺少的,爲什麼它通過單擊的exe
UPDATE
工作了Visual Studio 2010和沒有調試deirectory的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);
僅供參考 - 失蹤,wrongSizes都列出
貌似你試圖使用具有的WinForms的Razor視圖引擎?爲什麼? – Yuck 2012-03-22 15:47:38
你有@Model聲明嗎? – 2012-03-22 15:48:27
更新我的問題與聲明 – Trace 2012-03-22 15:49:09