0

I have this code for my web-part for sharepoint:

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.Script.Serialization;
using Newtonsoft.Json.Linq;

namespace ScheduleWeeks.WP_ScheduleWeek
{
    public partial class WP_ScheduleWeekUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Params["jsonData"] != null)
            {
                string jsonStr = Request.Params["jsonData"];
                JObject root = JObject.Parse(jsonStr);
            }
            else
            {
                Response.Write("nothing there");
            }
        }  
    }
}

But it doesn't work and show an error like

[FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. Couldn't locate a file.]

But then I comment string "JObject root = JObject.Parse(jsonStr);" all works without any errors. What I do in a wrong way? P.S.: Json.net was installed with NuGet.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Nana
  • 31
  • 10
  • I don't know if it was right, but then I add json.net to the GAC, code began to work. – Nana Sep 26 '12 at 04:11
  • from the Properties window for that Newtonsoft reference check if CopyLocal is set to true/false ? its better to set it to true for 3rd party dlls. Also check the Path where it is referencing from. – Vignesh.N Sep 26 '12 at 06:42
  • If you are using WSP package for deployment check these steps http://stackoverflow.com/a/8434215/846068 – Oleg Savelyev Sep 27 '12 at 08:01
  • Thanks a lot =) last comment save me – Nana Sep 28 '12 at 03:31

0 Answers0