在ServiceStack 4剃刀依赖问题 [英] Razor dependency issues in ServiceStack 4

查看:129
本文介绍了在ServiceStack 4剃刀依赖问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想一个应用程序升级到ServiceStack 4,但我在<$ C $获取与基准的误差 System.Web.WebPages.Razor C>的Web.config :

I'm trying to upgrade an app to ServiceStack 4 but I'm getting an error with the reference to System.Web.WebPages.Razor in Web.config:

无法加载文件或程序集System.Web.WebPages.Razor, 版本1.0.0.0 = ,文化=中性公钥= 31bf3856ad364e35或它的一个依赖。该系统不能找到指定的文件

Could not load file or assembly 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

的违规参考是完全相同的被包括在各种ServiceStack示例:

The offending reference is the exact same that is included in various ServiceStack examples:

 <compilation targetFramework="4.5" debug="true">
   <assemblies>
     <add assembly="System.Web.WebPages.Razor, 
          Version=1.0.0.0, 
          Culture=neutral, 
          PublicKeyToken=31BF3856AD364E35"/>
   </assemblies>
   ...



我试图运行官方例子(的剃刀的RockStar EmailContacts ),但我也得到同样的错误,当我运行它们。

I tried to run the official examples (Razor RockStar and EmailContacts) but I'm also getting the same error when I run them.

如果我更改了库声明使用版本= 2.0。 0.0 而不是,我没有得到任何错误

If I change the library declaration to use Version=2.0.0.0 instead, I'm not getting any error.

所以我的问题是:

是错误的例子,他们应该被移动到2.0.0.0,以及还是我做错了什么。

Are the example wrong and should they be moved to 2.0.0.0 as well or am I doing something wrong?

我的设置:


  • 的Windows 8.1专业版的x64

  • 的Visual Studio 2013专业版

  • 应用定位对于.NET 4.5,86

  • ServiceStack 4.0.15

  • Windows 8.1 Pro x64
  • Visual Studio 2013 Pro
  • App targeting for .Net 4.5, x86
  • ServiceStack 4.0.15

推荐答案

ServiceStack.Razor 添加的剃刀的Web.config部分通常使用ASP的版本。这是您计算机上安装NET网页包含VS.NET安装和更新,并在通常位于:

The razor Web.config sections added by ServiceStack.Razor normally use the version of ASP.NET WebPages that's installed on your computer included with VS.NET installation and updates and is normally located under:

C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\

这成立安装不同版本的ASP.NET网页,例如:

This holds the different version of ASP.NET Web pages installed, e.g:

v1.0\
v2.0\

安装的 ASP.NET网页是通过的NuGet,即:

Another option for installing ASP.NET WebPages is via NuGet, i.e:

PM> Install-Package Microsoft.AspNet.WebPages

这将安装最新版本的网页的目前为V3 .1.1并意味着你需要在Web.config改变版本号版本= 3.0.0.0

This will install the latest version of WebPages which is currently at v3.1.1 and means you would need to change the version number in the Web.config to Version=3.0.0.0.

您可以安装具体的1.0.0.0版本的ASP.NET Web页面:

You can install the specific 1.0.0.0 version of ASP.NET Web pages with:

PM> Install-Package Microsoft.AspNet.WebPages -Version 1.0.20105.408



使用

仅配置部分



ServiceStack不使用网页中实现自身的配置主要包括保持VS.NET智能影音感高兴,并提供一个方法来配置加入到剃刀页的默认命名空间。

Only configuration section used

ServiceStack doesn't use the WebPages implementation itself, the configuration is primarily included to keep VS.NET intelli-sense happy as well as providing a way to configure the default namespaces added to Razor pages.

虽然这也可以在代码中通过向 Config.RazorNamespaces 集合,但将它们添加到完成配置部分可让VS.NET知道他们这样你就可以得到适当的INTELL检测,否则它不会对在运行时,页面的执行产生任何影响。

Although this can also be done in code by adding to the Config.RazorNamespaces collection, but adding them to the config section lets VS.NET knows about them so you can get proper intell-sense, otherwise it doesn't have any effect on the execution of the pages at runtime.

这篇关于在ServiceStack 4剃刀依赖问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆