Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8332337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:41:35+00:00 2026-06-09T02:41:35+00:00

I get a null reference exception when I try to use this webservice I’m

  • 0

I get a null reference exception when I try to use this webservice I’m working on. I have two fields in the object ipadarticle called fullname and tags, which are declared to be lists, so that ipadarticle can return multiple tags and authors. The null reference exception points to

ipadarticle2.FullName.Add(a_var.firstname + " " + a_var.lastname)
ipadarticle2.Tag.Add(a_var.tagtext)

I’m pretty new to vb programming, so I’m not really to sure what is causing this. To clarify, what is going on is that this stored procedure is fetching entries from a db, which has a list of articles with -among other things- tags and authors associated with it. Since articles have multiple tags and authors there are multiple entries for each article. When I return the info in the web service I am trying to make it so that only one ipadarticle object is returned for reach article, and then that contains a list of the multiple tags and authors associated with each article. I’m having a headache trying to figure this out.

            Dim lq As New lqDFDataContext
            Dim var = lq.mobile_IpadGetSavedArticlesAR(simpuser.UserID, tempParamKW(0), tempParamKW(1), tempParamKW(2), tempParamKW(3), tempParamKW(4), pageNum, pageLen)
            Dim ipadarticle2 As New ipadArticle()

        For Each a_var In var



            If a_var.articleID <> temp Then

                If flag = 0 Then
                    result.add(ipadarticle2)
                    Dim ipadarticle1 As New ipadArticle()
                    ipadarticle2 = ipadarticle1
                End If

                ipadarticle2.ArticleID = a_var.articleID
                ipadarticle2.PublishedOn = a_var.publicationdate
                ipadarticle2.Title = a_var.title
                ipadarticle2.MedAbbr = a_var.medabbr.Replace(" ", "-").ToLower()
                ipadarticle2.FullName.Add(a_var.firstname + " " + a_var.lastname)
                ipadarticle2.Tag.Add(a_var.tagtext)

                flag = 1

            Else
                ipadarticle2.Tag.Add(a_var.tagtext)
                ipadarticle2.FullName.Add(a_var.firstname + " " + a_var.lastname)
                flag = 0
            End If

            temp = a_var.articleID

        Next
    End If
    Return result

ipadArticle class:

Imports Microsoft.VisualBasic

Public Class ipadArticle
    Inherits SimpleObject

    Public Sub New()

    End Sub



    Private _ArticleID As Integer
    Public Property ArticleID() As Integer
        Get
            Return _ArticleID
        End Get
        Set(ByVal value As Integer)
            _ArticleID = value
        End Set
    End Property


    Private _Title As String
    Public Property Title() As String
        Get
            Return _Title
        End Get
        Set(ByVal value As String)
            _Title = value
        End Set
    End Property
    Private _PublishedOn As String
    Public Property PublishedOn() As String
        Get
            Return _PublishedOn
        End Get
        Set(ByVal value As String)
            _PublishedOn = value
        End Set
    End Property


    Private _MedAbbr As String
    Public Property MedAbbr() As String
        Get
            Return _MedAbbr
        End Get
        Set(ByVal value As String)
            _MedAbbr = value
        End Set
    End Property

    Private _Tag As List(Of String)
    Public Property Tag() As List(Of String)
        Get
            Return _Tag
        End Get
        Set(ByVal value As List(Of String))
            _Tag = value
        End Set
    End Property

    Private _FullName As List(Of String)
    Public Property FullName() As List(Of String)
        Get
            Return _FullName
        End Get
        Set(ByVal value As List(Of String))
            _FullName = value
        End Set
    End Property


End Class
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T02:41:37+00:00Added an answer on June 9, 2026 at 2:41 am

    The most likely cause is that the objects FullName and Tag have not been created (are Nothing) in ipadarticle2. These should most likely be created as new objects in the class constructor.

    EDIT:

    Based on the posted class, the above assumption was correct: FullName and Tag are defined as List(Of String), but the backing members are never created.

    This can be fixed in a couple of ways:

    1) Instantiate the backing member variables directly in their definition, i.e.:

    Private _FullName As New List(Of String)
    

    2) Instantiate the backing member variables in the constructor:

    Public Sub New()
      _FullName = New List(Of String)
      _Tag = New List(Of String)
    End Sub
    

    3) Instantiate the backing member variable in the getter if it is nothing:

    Public Property Tag() As List(Of String)
    Get
    If _Tag Is Nothing Then
    _Tag = New List(Of String)
    End If
    Return _Tag
    End Get

    Basically, any variable types other than simple data types must be instantiated before they can be used (unless you test them for Nothingness).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C# application..I continuously get a null reference exception..I manage to catch
So, I get this System.NullReferenceException Object reference not set to an instance of an
I get a null - reference in this Code-line: **DataRow dr = tableSelectedItems.NewRow();** I
I have a method that is structured like this: public object Get(int intId, int
P/Invoke on x64 null reference exceptions I get null reference exceptions when I try
I'm trying to get a reference to cell and it appears null. If I'm
I get the following error on firebug: this._processor is null and the error is
Can someone tell me why I get the null value for activationLink variable in
In Java, is it possible to attempt a cast and get back null if
Can get all triples with value null in specific field? All people with date_of_birth

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.