Results 1 to 2 of 2

Thread: website gets error "Type 'JObject' is not defined" (Newtonsoft.json)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2017

    website gets error "Type 'JObject' is not defined" (Newtonsoft.json)

    This works in Visual Studio.
    It does not work on `Windows 2016 Server Core` running `IIS 10`.
    When published, there are no issues.
    Run the website on the server, I receive the error `Type 'JObject' is not defined.`.
    Code line: `Dim parsejson As JObject = JObject.Parse(json)`

    All imports are there.

        Imports Newtonsoft.Json
        Imports Newtonsoft.Json.Linq

    The `Bin` folder contains.
    Newtonsoft.Json.dll (Version #

    I thought maybe registering the .dll file with `gacutil -i Newtonsoft.Json.dll` would resolve the issue, but it is not registerable.
    When run, it adds it to the `cache`.
    But when running `gacutil -l Newtonsoft.Json.dll`
    I get `Invalid file or assembly name`
    So, it is unregisterable.

    I added this to the `web.config`, but the issue is still the same.

                <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="" newVersion="" />
    I wanted to add this as the code I am using.
    VB.NET Code To Parse Child Node Of JSON (Second code at the bottom)
    I am not using [brackets] only {curly brackets}.

    An example of the JSON can be found at the link above. (Broken into lines to fit code view better)
    To view the actual JSON
        {"id":3,"name":"true red","year":2002,"color":"#BF1932","pantone_value":"19-1664"}
        "To keep ReqRes free, contributions towards server costs are appreciated!"}}
    The code I am using.
         Imports System.Net
            Imports Newtonsoft.Json.Linq
            Public Class Form1
                Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
                    Dim json As String = New System.Net.WebClient().DownloadString("")
                    Dim parsejson As JObject = JObject.Parse(json)
                    Dim thename = parsejson.SelectToken("").ToString()
                    txt1.Text = "Name Is " + thename
                End Sub
            End Class

  2. #2

    Thread Starter
    Junior Member
    Join Date
    Feb 2017

    Re: website gets error "Type 'JObject' is not defined" (Newtonsoft.json)

    I had to remember what I had done years ago.
    In IIS, Right-click on the folder from which the script is running.
    Choose: Convert to Application.
    Refresh the website in your browser, and everything went to working.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width