如果我在 VS2010 中创建一个新项目并按照这些简单的步骤添加 ServiceStack ......我得到一个无法构建的项目,我不知道该怎么做......从谷歌搜索看来它可能有一些东西与 Web.config 相关......但它超出了我的范围。有什么帮助吗?
Visual Studio 2010
文件 -> 新建 -> 网站... ASP.NET 网站(Razor)
编译没问题
右键单击项目 -> 管理 NuGet 包
搜索“ServiceStack.Razor”
找到 1 项并单击
全部安装重建,我得到大约 8这些错误:
错误 1 命名空间“Razor”已包含“__CompiledTemplate”c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\backend\6f939f81\a07fd23c\App_Web_rw2opozl.3 的定义。 cs 15
错误 2 命名空间“Razor”已包含“__CompiledTemplate”的定义 c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\backend\6f939f81\a07fd23c\App_Web_rw2opozl.0.cs 15
ETC…
Web.config 文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web>
<compilation debug="true" targetFramework="4.0"><assemblies>
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies><buildProviders>
<add extension=".cshtml" type="ServiceStack.Razor.CSharpRazorBuildProvider, ServiceStack.Razor" />
</buildProviders></compilation>
</system.web>
<connectionStrings>
<add name="StarterSite" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\StarterSite.mdf;User instance=true" providerName="System.Data.SqlClient" />
</connectionStrings>
<appSettings>
<add key="webPages:Enabled" value="false" />
</appSettings><system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="ServiceStack.Razor.ViewPage">
<namespaces>
<add namespace="ServiceStack.Html" />
<add namespace="ServiceStack.Razor" />
<add namespace="ServiceStack.Text" />
<add namespace="ServiceStack.OrmLite" />
<add namespace="ASP" />
</namespaces>
</pages>
</system.web.webPages.razor></configuration>