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 6882139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:12:59+00:00 2026-05-27T05:12:59+00:00

I have a VB.NET singleton class which implements Serializable : Imports System.IO Imports System.Runtime.Serialization

  • 0

I have a VB.NET singleton class which implements Serializable:

Imports System.IO
Imports System.Runtime.Serialization

<Serializable()> Public Class CoordinateHistory
    Private Shared _thisInstance As CoordinateHistory

    Private gpsHistory As Dictionary(Of DateTime, GpsTimeCoordinate)
    Private gpsTimes As List(Of DateTime)

    Public Event NewStatusInformation(statusInfo As String)

    Protected Sub New()
        gpsHistory = New Dictionary(Of DateTime, GpsTimeCoordinate)
        gpsTimes = New List(Of DateTime)
    End Sub

    Public Shared Function getInstance() As CoordinateHistory
        If _thisInstance Is Nothing Then
            _thisInstance = New CoordinateHistory
        End If

        Return _thisInstance
    End Function

    Public Function getHistoryCount() As Integer
        Return gpsHistory.Count
    End Function

    ' bunch of other class functions below...
End Class

My problem is that I can’t actually call .Serialize() on the instance of this class, like all of the examples online show. What am I doing wrong? Thanks!

  • 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-05-27T05:13:00+00:00Added an answer on May 27, 2026 at 5:13 am

    I believe the issue is your Protected Sub. If you change it to Public, you may be able to Serialize correctly.

    Update

    I didn’t have any issues serializing the default instance using a BinaryFormatter:

    Dim abData As Byte()
    
    Using oStream As New MemoryStream
        Call (New BinaryFormatter).Serialize(oStream, CoordinateHistory.getInstance())
    
        abData = oStream.ToArray()
    End Using
    

    or an XMLFormatter:

    Dim sData As String
    
    Using oStream As New MemoryStream
        Dim oSerializer As New XmlSerializer(CoordinateHistory.getInstance().GetType)
    
        oSerializer.Serialize(oStream, CoordinateHistory.getInstance())
    
        sData = Encoding.Default.GetString(oStream.ToArray())
    End Using
    

    Perhaps it is the serialization framework you are using?

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

Sidebar

Related Questions

I have created a Registry class in .NET which is a singleton. Apparently this
We have a concrete singleton service which implements Ninject.IInitializable and 2 interfaces. Problem is
I have a method in a singleton class that need to use the .NET
I am using .net 1.1. I have a session class in which I have
I have a Windows Mobile 6.5 (.net cf 3.5) that uses a singleton class
If we have a singleton class like LoadBalancer and need one instance per ASP.NET
I'm using ASP.NET MVC 3 and have my custom model binder. public class NewsModelBinder
1) .NET Assembly MyAssembly.dll implements a Singleton class MyClass 2) A .NET APP has
I have veeeeryyy basic singleton in asp.net web application: [ThreadStatic] private static BackgroundProcessManager2 _Instance;
Does .NET have anything similar to Perl arrays, which are indexed numerically but automatically

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.