相关疑难解决方法(0)

为什么我得到'无法找到编译动态表达式所需的一种或多种类型.'?

我有一个项目,我已经更新

  • .NET 3.5 MVC v2到
  • .NET 4.0 MVC v3

编译我尝试使用或设置@ViewBag.Title属性时收到错误.

无法找到编译动态表达式所需的一种或多种类型.您是否缺少对Microsoft.CSharp.dll和System.Core.dll的引用?

我做了以下事情

  1. 遵循升级步骤
  2. 将Project/Properties/Application选项卡中的目标框架设置为.NET Framwework 4
  3. 手动添加了System.Core框架
  4. 添加了Microsoft.CSharp框架
  5. 添加了System.Xml框架
  6. 添加了System.Xml.Linq框架
  7. 确保我的Web.Config是正确的(它由Web.Debug.Config等编写)
  8. 创建了模型,控制器和Razor View
  9. 创建__Layout.cshtml_

我不知道还能做什么?

编辑:

我注意到在GAC Gui中有System.Core 3.5.0.0但没有System.Core 4.0.0.0.这是否意味着它变得困惑并仍在使用以前的版本?或者我误解了GAC?

编辑:

我的web.config看起来如下

...
<compilation debug="true">
    <assemblies>
        <add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc c#-4.0

61
推荐指数
8
解决办法
7万
查看次数

Viewbag.Title错误:无法找到编译动态表达式所需的一种或多种类型.你错过了参考吗?

我有一个ASP.NET MVC 5 Web应用程序.在每个.cshtml视图文件中,我收到Viewbag的以下错误:无法找到编译动态表达式所需的一个或多个类型.你错过了参考吗?

我引用了Microsoft.CSharp.dll和System.Core.dll.

这是我的根web.config文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>
    <add name="DefaultConnection" connectionString="***" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="3.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="RouteDebugger:Disabled" value="true" />
  </appSettings>
  <system.web>
    <authentication mode="None" />
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <globalization culture="ro-RO" uiCulture="ro" />
  </system.web>
  <system.webServer>
    <modules>
      <remove name="FormsAuthenticationModule" />
    </modules>
  </system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly> …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc razor asp.net-mvc-5

11
推荐指数
2
解决办法
2万
查看次数

标签 统计

asp.net-mvc ×2

asp.net-mvc-5 ×1

c# ×1

c#-4.0 ×1

razor ×1