Quote:You must implement a default accessor on Newtonsoft.Json.Linq.JObject because it inherits from ICollection. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.InvalidOperationException: You must implement a default accessor on Newtonsoft.Json.Linq.JObject because it inherits from ICollection. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [InvalidOperationException: You must implement a default accessor on Newtonsoft.Json.Linq.JObject because it inherits from ICollection.] System.Xml.Serialization.TypeScope.GetDefaultIndexer(Type type, String memberInfo) +5361982 System.Xml.Serialization.TypeScope.ImportTypeDesc(Type type, MemberInfo memberInfo, Boolean directReference) +1475 System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError) +157 System.Xml.Serialization.XmlReflectionImporter.ImportMemberMapping(XmlReflectionMember xmlReflectionMember, String ns, XmlReflectionMember[] xmlReflectionMembers, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +71 System.Xml.Serialization.XmlReflectionImporter.ImportMembersMapping(XmlReflectionMember[] xmlReflectionMembers, String ns, Boolean hasWrapperElement, Boolean rpc, Boolean openModel, RecursionLimiter limiter) +300
I am using VS2017 below is the code that i have created : <pre lang="vb"> <blockquote class="quote"><div class="op">Quote:</div> Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.ComponentModel Imports Newtonsoft.Json Imports Newtonsoft.Json.Linq Imports System.Net Imports System.Data.SqlClient Imports System.IO <blockquote class="quote"><div class="op">Quote:</div><System.Web.Services.WebService(Namespace:="http://tempuri.org/")> <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> <ToolboxItem(False)> Public Class CovidWebService</blockquote> <WebMethod> Public Function SubGetVisitorsListNew(ByVal jsonResult As JObject) As String Dim mMsg As String = "Done" MyConConnection.Open() Try Dim details = JObject.Parse(jsonResult) Dim ser As JObject = JObject.Parse(jsonResult) Dim data As List(Of JToken) = ser.Children().ToList Dim output As String = "" For Each item As JProperty In data item.CreateReader() Select Case item.Name Case "visitors" For Each msg As JObject In item.Values mCmd = "INSERT INTO SurveyVisitorsData " mCmd = mCmd & " (FamilyHeadSerialNo, Name,Age, AgeDetails, Sex, IfUNRResident) " mCmd = mCmd & " VALUES " mCmd = mCmd & " (@mFamilyHeadSerialNo, @mName,@mAge, @mAgeDetails, @mSex, @mIfUNRResident) " cmd = New SqlCommand(mCmd, MyConConnection) cmd.Parameters.AddWithValue("@mFamilyHeadSerialNo", msg("FamilyHeadSerialNo")) cmd.Parameters.AddWithValue("Name", msg("Name")) cmd.Parameters.AddWithValue("contact_number", msg("contact_number")) cmd.Parameters.AddWithValue("Age", msg("Age")) cmd.Parameters.AddWithValue("AgeDetails", msg("AgeDetails")) cmd.Parameters.AddWithValue("Sex", msg("Sex")) cmd.Parameters.AddWithValue("IfUNRResident", msg("IfUNRResident")) cmd.ExecuteNonQuery() Next End Select Next Catch ex As Exception mMsg = ex.Message.ToString End Try MyConConnection.Close() Return mMsg End Function End Class </blockquote>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)