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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T02:28:15+00:00 2026-05-21T02:28:15+00:00

I have a .NET remoting client activated object type client-server application. I’m using Visual

  • 0

I have a .NET remoting client activated object type client-server application. I’m using Visual Studio 2010 targeting the .NET Framework 4. When I run without debugging, the program works fine – the clients can connect no problem. But when I try to debug, on the line in the client code where I have the ‘new’ operator, the server (I think) throws an exception.

What I want to do is keep references to the remote objects created in the server code. So in my Remote Object’s constructor I have this line:

Cache.GetInstance().addFireFighter(this);

When I debug, this code runs fine too. But when it goes back to the remote object’s line to call the addFireFighter method, that’s when it crashes. Here’s the addFireFighter method:

public static IServer _server;

public void addFireFighter(FireFighter ff)
{
    _server.addFireFighter(ff);
}

And the _server.addFireFighter method:

public void addFireFighter(FireFighterResponder.FireFighter ff)
{
    _ffList.Add(ff); // -> works fine :S
    Console.WriteLine("FireFighterResponder addFireFighter added");
    lstBox.Items.Add(ff); //-> CRASH!!
}

Observation: When I run the server without debugging but run the client in debug mode, it still works fine.

This is a school project and I’m new to C# .NET remoting. I implemented the same in Java and had no issue. So I can give my whole project if somebody wants to look at it. Maybe I have a design flaw.

Here’s the stack trace:

System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Cross-thread operation not valid: Control 'lstBox' accessed from a thread other than the thread it was created on.
   at System.Windows.Forms.Control.get_Handle()
   at System.Windows.Forms.ListBox.NativeAdd(Object item)
   at System.Windows.Forms.ListBox.ObjectCollection.AddInternal(Object item)
   at System.Windows.Forms.ListBox.ObjectCollection.Add(Object item)
   at FirefighterMonitorSystem.BaseStation.addFireFighter(FireFighter ff) in C:\Users\Dula\Documents\My Dropbox\Firefighter\453\FirefighterMonitorSystem\FirefighterMonitorSystem\BaseStation.cs:line 35
   at FireFighterResponder.Cache.addFireFighter(FireFighter ff) in C:\Users\Dula\Documents\My Dropbox\Firefighter\453\FirefighterMonitorSystem\FireFighterResponder\Cache.cs:line 33
   at FireFighterResponder.FireFighter..ctor() in C:\Users\Dula\Documents\My Dropbox\Firefighter\453\FirefighterMonitorSystem\FireFighterResponder\FireFighter.cs:line 20
   --- End of inner exception stack trace ---

The lstBox is a .NET ListBox in my server code where I add each Remote object. But what still confuses me is why it works when not in debug mode.

  • 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-21T02:28:16+00:00Added an answer on May 21, 2026 at 2:28 am

    You have to look at the exception’s InnerException property to know what went really wrong.

    You are accessing a control from a thread other than the main thread (aka UI thread). This is illegal, windows are not thread-safe. You must use Control.Begin/Invoke(). You don’t get the exception without the debugger because this thread checking is only enabled by default when a debugger is attached. That doesn’t mean it is safe to run code without a debugger, it will randomly cause paint problems or deadlock, although you may have to wait a day or a week for that to happen.

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

Sidebar

Related Questions

I have a client-server application that uses .net remoting. The clients are in a
I have a client/server application that communicates with .Net remoting. I need my clients
I have a client and a server application which communicate over .NET 2.0 Remoting
I have a visual studio 2008 solution that includes an asp.net-hosted remoting project in
I have what I thought was a simple .NET Remoting Client/Server (Code Below)... When
I have an ASP.Net web application, which interacts with .Net Remoting application server. As
I have server application writed in .net. To connect with this server I'm using
I have some .NET remoting code where a factory method, implemented in some server
I have a complex .NET Remoting server app that provides a couple of services.
I have a .NET application, which is using an open source C++ compression library

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.