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

  • Home
  • SEARCH
  • 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 8871585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:01:27+00:00 2026-06-14T18:01:27+00:00

I have a class in an assembly that I wish to be a singleton.

  • 0

I have a class in an assembly that I wish to be a singleton. I want it to be created by my Server application then allow Another application on the same machine to access this class instance.

I am using this lazy loading implementation to ensure only one instance exists:

Private Shared ReadOnly _instance As New Lazy(Of PersonX)(Function() New PersonX(), System.Threading.LazyThreadSafetyMode.ExecutionAndPublication)

Public Shared ReadOnly Property Instance() As PersonX
    Get
        Return _instance.Value
    End Get
End Property

And then I am using a Private Sub New with the following remoting code:

Dim uri As String = String.Format("tcp://{0}:{1}/PersonX", "localhost", 1976)
RemotingServices.Marshal(Person.Instance, uri)
RemotingConfiguration.RegisterActivatedServiceType(GetType(PersonX))

The in my Calling code I create my first instance with:

Dim PersonX as SingletonTestClass.PersonX = SingletonTestClass.PersonX.Instance

I am using the following code to connect to the instance using remoting:

Dim newPerson As SingletonTestClass.PersonX
Dim uri As String = String.Format("tcp://{0}:{1}/PersonX", "localhost", 1976)
newPerson = CType(Activator.GetObject(GetType(SingletonTestClass.PersonX), uri), SingletonTestClass.PersonX)

But now when I try to access the object properties I get an error Requested Service not found on this line:

newPerson.Name = "Fred"
  • 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-14T18:01:29+00:00Added an answer on June 14, 2026 at 6:01 pm

    To answer your question, you need to register a channel before you marshal your Remoting object:

    See simple, working C# example:

    public class Test : MarshalByRefObject
        {
            public string Echo(string message)
            {
                return "Echo: " + message;
            }
        }
    
    private void button1_Click(object sender, EventArgs e)
            {
                ChannelServices.RegisterChannel(new TcpChannel(1234));
                Test test1 = new Test();
                RemotingServices.Marshal(test1, "TestService");
    
                Test test2 = (Test)Activator.GetObject(typeof(Test), "tcp://localhost:1234/TestService");
                MessageBox.Show(test2.Echo("Hey!"));
            }
    

    Ensure firewall is not blocking port.

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

Sidebar

Related Questions

I have created a class library (assembly) that provides messaging, email and sms. This
i have a winforms project, and i created a class on assembly A that
I have a class that is in an assembly due to being required for
I have a WCF server that is a library assembly. (I am writing it
I have an assembly that provides the class structure for a custom config section.
I have assembly A that depends (statically) on type T (reference type, a class)
I have standard class library infrastructure assembly which i reference in my main application.
I have F# class library assembly that contains two functions: let add a b
I have an assembly (class library project in .Net 3.5) that has some references
I have a .net assembly that exposes a public class (named A) to be

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.