类型或命名空间名称'动态'找不到 [英] The type or namespace name 'dynamic' could not be found

查看:691
本文介绍了类型或命名空间名称'动态'找不到的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

微软的Visual Studio 2010旗舰版(版本10.0.40219.1 SP1Rel)。

Microsoft Visual Studio 2010 Ultimate (Version 10.0.40219.1 SP1Rel).

Microsoft .NET Framework版本4.5.50709 SP1Rel

Microsoft .NET Framework version 4.5.50709 SP1Rel

我要编译的.NET Framework 4.0。

I am compiling to .net framework 4.0.

每当我尝试使用动态或VAR数据类型,我得到在主题行中显示的错误:

Whenever I try to use the dynamic or var data types, I get the error shown in the subject line:

类型或命名空间名称'动态'找不到。

The type or namespace name 'dynamic' could not be found.

类型或命名空间名称'变种'找不到。

The type or namespace name 'var' could not be found.

我想使用JsonFX来分析,我从另一个Web服务接收数据。有时候数据会重新present一个消息,有时它会重新present一个跟踪。根据这一 JsonFx文档,我应该能够效仿的序列化/从动态类型(默认为.NET 4.0):

I am trying to use JsonFX to parse data that I receive from another web service. Sometimes with data will represent a "message", and sometimes it will represent a "track". According to this JsonFx Documentation, I should be able to follow the example for "Serialize to/from dynamic types (default for .NET 4.0):"

我添加了一个页面到我的网站被称为测试。下面的code块是从Test.aspx.cs 在code我想使用是这样的:

I added a page to my site called test. The code block below is from Test.aspx.cs The code I am trying to use is this:

using System;
using System.Text;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using JsonFx;
using JsonFx.Json;
using Microsoft.CSharp;

public partial class Test : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string Data = "";
        Data = @"[{""meta"":{""account"":""orbitinte"",""event"":""track""},""payload"":{""id"":410827200397312213,""id_str"":""410827200397312213"",""asset"":""359551031717134"",""recorded_at"":""2013-02-07T15:59:04Z"",""received_at"":""2013-02-07T16:00:37Z"",""fields"":{}}},{""meta"":{""account"":""orbitinte"",""event"":""track""},""payload"":{""id"":410827200409895125,""id_str"":""410827200409895125"",""asset"":""359551031717134"",""recorded_at"":""2013-02-07T16:00:04Z"",""received_at"":""2013-02-07T16:00:37Z"",""fields"":{}}}]";
        Data = @"[{""meta"":{""account"":""orbitinte"",""event"":""message""},""payload"":{""id"":410865901198377173,""thread_id"":null,""parent_id"":410865891354345685,""id_str"":""410865901198377173"",""thread_id_str"":"""",""parent_id_str"":""410865891354345685"",""type"":""message"",""channel"":""com.mdi.services.adminProtocol"",""sender"":""359551031717134"",""recipient"":""@@server@@"",""asset"":""359551031717134"",""b64_payload"":""eyJlcnJvciI6ImNhbm5vdCBwYXJzZSBjb21tYW5kIn0="",""recorded_at"":""2013-02-07T18:34:25Z"",""received_at"":""2013-02-07T18:34:24Z""}}]";


        JsonReader Reader = new JsonReader();
        dynamic Output = Reader.Read(Data);

        Notifications oNotifications = new Notifications();
        oNotifications.ProcessNotifications(Data);
    }
}

在web.config文件:

In the web.config file:

  <system.codedom>
    <compilers>
      <compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
        <providerOption name="CompilerVersion" value="v4.0"/>
        <providerOption name="WarnAsError" value="false"/>
      </compiler>
    </compilers>
  </system.codedom>

我是相当新的C#和asp.net。但是,我一直在寻找一个解决这个问题,而现在。我看到的一切提到了编译器版本和.NET Framework版本。我想我已经提供了所有的相关细节,但如果有什么事我应该加入到这个问题,请让我知道。

I am fairly new to C# and asp.net. But I've been searching for a solution to this problem for a while now. Everything I see mentions the compiler version and the .net framework version. I think I have provided all of the relevant details, but if there is anything else I should add to this question, please let me know.

推荐答案

在IIS网站配置为使用.NET 2.0?这就是它听起来像我。首先检查配置..没有你的测试工作在本地?

Is your website in IIS configured to use .NET 2.0 ? That's what it sounds like to me. Check the configuration first.. does your test work locally ?

您的编译器应该是这样的:

Your compiler should look like this:

<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

你的是设置为版本= 2.0.0.0

Yours is set to Version=2.0.0.0

这篇关于类型或命名空间名称'动态'找不到的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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