473,569 Members | 2,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Showing Form using .NET Remoting

I have a Form class that can be open by parent Form or by .NET Remoting
command.
When the parent Form opens the Form - All fine !
But when the .NET Remoting command is trying to Show the Form, the Form
stuck !! I tried to change the Remoting delegate invocation to asynchronous
and to synchronous, yet both cause the same Form Show() to stuck.
When I mean stuck, I mean the the Form is shown but non of it controls are
shown, only gray window that does not respond.

Both the parent Form and the Remoting command are invoking the same method
to Showing the Form, here is the code:

public void OpenViewForm(bo ol topMost)
{
m_Viewer = new ViewerForm();
m_Viewer.TopMos t = topMost;
m_Viewer.Show() ;
m_Viewer.BringT oFront();
}

Any idea why the remoting cause this and how can I fix this?
---------
Thanks
Sharon
Nov 17 '05 #1
2 2481
Ok, I found the problem:

The remoting method is being called on a seperate thread to the main thread
- therefore it has no message loop.

The remoting class must have to have access to one of the elements of the UI
(e.g. the main form).

Then calling a method on this form using Invoke, and bringing up of the form
in there.

i.e.

public class MainForm : Form
{
static MainForm m_formCurrent = null;

static public Current
{
get
{
return m_form;
}
}

private Viewer m_Viewer;

public MainForm()
{
m_formCurrent = this;
// etc etc
}

public void OpenViewForm()
{
m_Viewer = new ViewerForm();
m_Viewer.Show() ;
m_Viewer.BringT oFront();
}
}

// in theremoting class
MainForm.Curren t.Invoke(new MethodInvoker(M ainForm.Current .OpenViewForm)) ;

All calls to the viewer should be marshalled like this : by using delegates.
Nov 17 '05 #2
Thats because the remoting call is coming in on a threadpool thread which does not run a message pump.

In your Main of the remote process do something like

Form1 f ;
delegate void ShowFormDel();

static void Main()
{
f = new Form1();
RemotingConfigu ration.Configur e(...);
Application.Run ();
}

Then in the remoted call say
f.BeginInvoke(n ew ShowFormDel(f.S how), new object[]{});

Now this will marshall the call to show on to the UI thread which is running a message pump and so will show the form successfully.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk

I have a Form class that can be open by parent Form or by .NET Remoting
command.
When the parent Form opens the Form - All fine !
But when the .NET Remoting command is trying to Show the Form, the Form
stuck !! I tried to change the Remoting delegate invocation to asynchronous
and to synchronous, yet both cause the same Form Show() to stuck.
When I mean stuck, I mean the the Form is shown but non of it controls are
shown, only gray window that does not respond.

Both the parent Form and the Remoting command are invoking the same method
to Showing the Form, here is the code:

public void OpenViewForm(bo ol topMost)
{
m_Viewer = new ViewerForm();
m_Viewer.TopMos t = topMost;
m_Viewer.Show() ;
m_Viewer.BringT oFront();
}

Any idea why the remoting cause this and how can I fix this?
---------
Thanks
Sharon

[microsoft.publi c.dotnet.langua ges.csharp]
Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1168
by: menkaur | last post by:
I was writing simple test program for using class libraries (OS: Windows 2003 Server). The problem I’ve got: runtime error: ------------------------------------------- An unhandled exception of type 'System.Runtime.Remoting.RemotingException' occurred in mscorlib.dll Additional information: Remoting configuration failed with the exception...
1
4985
by: Claire | last post by:
I've written a Windows Service application that monitors input through a com port. It's been requested that I add a dialog box so that, should anyone need to watch the input for troubleshooting reasons, they can. I remember that I had to call a version of the MessageBox() function that uses MessageBoxOptions = "ServiceNotification" on one...
3
4462
by: Rob | last post by:
Can a form be opened from a Windows service? I have a windows service that I would like to open a form from a notify icon. I cannot get the Notify Icon to display nor can I open a form. Any help would be greatly appreciated. Rob
0
1601
by: feng | last post by:
Hi, I am having a strange problem right now and I don't even know how to go about it. Someone please help me! Any inputs will be highly appreciated. We have an application that has a VB.Net windows form front-end and a middle tier that's also in VB.Net. The two talk to each other via .Net Remoting. If we just run the windows form exe...
5
2197
by: Szafranr | last post by:
Hi everyone, I have NT service from which I try to display window form. This form is created in sub New. In servise I implemented OnCustomCommand handle, when I wait for command 129 and for this command I try to do form.Show() but I can't see this window :-( I checked by filelog - form_load is running after send command. Is possible to...
3
7682
by: tman | last post by:
OK so I built this Windows Service which was able to use MessageBox.Show to present text to the user from within the service. I had to use a special property though within that method- which is MessageBoxOptions.ServiceNotification. Now I'd like to create a custom form and have the service show it, to administer settings of that service....
1
1411
by: abc | last post by:
How to decide the best choice between web-form and win-form for the next solution? In my case, the new projects will have over 200 users to use and we will apply part-by-part function components add to production environment when we developed a part and parts. The projects will have a very very user friendly UI for powerful analysis and...
7
2167
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I am trying to see if I can call a Library remotely. The library contains a Form that I want to display then pass back some data to user that called this form remotely. I have it working some-what. I am able to call form remotely and return data to client but somewhere after closing remote form and returning data - I get a Windows...
7
1952
by: =?Utf-8?B?TWF0dA==?= | last post by:
Hi I have an app that runs without a main form, just a notification icon, when the user clicks the icon the form is shown, and when the form is minimized it's hidden. This all works great, and I have implemented single instance so that when another instance is run, an event gets signalled in the 1st instance, and what I would like to do...
0
7700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7614
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3653
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.