Microsoft Visual Studio 2010 Ultimate (Version 10.0.40219.1 SP1Rel).
Microsoft .NET Framework version 4.5.50709 SP1Rel
I am compiling to .net framework 4.0.
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.
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):"
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);
}
}
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>
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.
Make sure you have a reference to Microsoft.CSharp
in your project.
A little more info on this DLL can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With