|
Closing the channel is the bit thats confusing me - its only a form within the app, so when I close that form, I need to close the current connection, so that when I relaunch the form again it will accept a new IP.
Im new to remoting, so sorry if I am missing something simple lol
Here is the full code to date:
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using System.Runtime.Remoting;<br />
using System.Runtime.Remoting.Channels;<br />
using System.Runtime.Remoting.Channels.Http;<br />
using RemProcs;<br />
<br />
namespace Softcode_Network_Tools<br />
{<br />
public partial class viewProcesses : Form<br />
{<br />
public viewProcesses()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
public Form1 frm1;<br />
public string connIP;<br />
public string connPORT = "8011";<br />
<br />
public void InitRemoteServer()<br />
{<br />
try<br />
{<br />
HttpChannel channel = new HttpChannel();<br />
ChannelServices.RegisterChannel(channel);<br />
RemotingConfiguration.RegisterWellKnownClientType(<br />
typeof(procDLL),<br />
"http://" + connIP + ":" + connPORT + "/procDLL");<br />
}<br />
catch (Exception ex)<br />
{<br />
<br />
}<br />
}<br />
<br />
private void viewProcesses_Load(object sender, EventArgs e)<br />
{<br />
try<br />
{<br />
this.Text = "View " + ((Form1)frm1).selected_name + "'s Processes";<br />
label1.Text = "Connecting to: " + ((Form1)frm1).selected_ip + "...";<br />
connIP = ((Form1)frm1).selected_ip;<br />
<br />
try<br />
{<br />
InitRemoteServer();<br />
}<br />
catch (Exception ex)<br />
{<br />
InitRemoteServer();<br />
}<br />
server1 = new procDLL();<br />
string allProcsRunning = server1.return_processes();<br />
string[] arrProcs = new string[200];<br />
char[] splitter = {':'};<br />
arrProcs = allProcsRunning.Split(splitter);<br />
this.listView1.Items.Clear();<br />
this.listView1.BeginUpdate();<br />
<br />
for (int x = 0; x < arrProcs.Length; x++)<br />
{<br />
if (arrProcs[x] != "-")<br />
{<br />
if (arrProcs[x] != " ")<br />
{<br />
if (arrProcs[x] != "")<br />
{<br />
ListViewItem lvi;<br />
lvi = new ListViewItem();<br />
lvi.Text = arrProcs[x];<br />
this.listView1.Items.Add(lvi);<br />
}<br />
}<br />
}<br />
}<br />
this.listView1.EndUpdate();<br />
listView1.Sorting = SortOrder.Ascending;<br />
label2.Text = "Windows Account Name: " + server1.return_user();<br />
label2.Visible = true;<br />
label1.Text = "Connected to: " + connIP + ".";<br />
}<br />
catch (Exception ex)<br />
{<br />
label1.Text = "Unable to connect to " + connIP + ".";<br />
MessageBox.Show(ex.ToString());<br />
}<br />
<br />
}<br />
<br />
private void button3_Click(object sender, EventArgs e)<br />
{<br />
this.Dispose();<br />
}<br />
}<br />
}
|
|
|
|
|
First : The code would be MUCH easier to view if you wrap it with <pre> and <\pre> instead of the code parameter.
Secondly : the code, as I read it, does not look good. For example, when you initialize the client you ignore exceptions. Not good. If you get a connection failure, your client is dead.
Finally : Does button3 close the application???? You should rename that to make it self-documenting. If it closes the form, then this.Dispose() will not close your connection for you!!! (Which is part of your problem)
I highly suggest you get get this book:
Advanced .Net Remoting 2nd Ed. Ingo Rammar/Mario Szpuszta (Apress 1590594177)
This is the top of the list for remoting education!!! It looks like you're creating your remote object incorrectly, there should be no reason for InitializeRemoteServer since InitializeClient does that job.
Good luck,
Michael
|
|
|
|
|
Hello I use WndProc(ref Message m) in a windows form.
If I use WndProc in a consol "dos" programm ( no windows form ) error message is :
WndProc(ref System.Windows.Forms.message) no suitable method found to override
Do you know why ? is this methoc can running in programm consol ?
Thanks
Vincent
|
|
|
|
|
You're not inheriting from a class which defines WndProc.
Sig cops got me...
|
|
|
|
|
Console applications don't normally setup their own Window message pump, so there's no WndProc in the Console class to override.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks very much for your answer.
Is it possible whith consol to detect usb Key insert ?
how replace this code for consol ? :
protected override void WndProc(ref Message m)
{
if (m.Msg == Native.WM_DEVICECHANGE)
{
if (!_loading)
{
LoadItems();
}
}
base.WndProc(ref m);
}
thanks again
Vincent
|
|
|
|
|
Well, you could run a message pump in your console app by calling Application.Run[^]. You could either create a hidden windows form, override the WndProc and pass that instance to Application.Run, or you could create a message filter, add it using Application.AddMessageFilter[^] and then simply call Application.Run .
|
|
|
|
|
thanks,
I am sorry I dont understant all.
In my consol programm how link application and event.
this is a part of my code, but dont work ?
An idea ?
thanks
namespace SYS_SERVEUR
{
class RemoteMain
{
[STAThread]
static void Main(string[] args)
{
lines of code ....
// here my new code to detect device change ?!?
TestMessageFilter mytest = new TestMessageFilter();
Application.AddMessageFilter(mytest);
Application.Run();
}
}
//here the event that I would like dtect ???
public class TestMessageFilter : IMessageFilter
{
protected const UInt32 WM_DEVICECHANGE = 0x0219;
public bool PreFilterMessage(ref Message m)
{
// Blocks all the messages relating to the left mouse button.
if (m.Msg == WM_DEVICECHANGE)
{
//Console.WriteLine("Processing the messages : " + m.Msg);
Console.WriteLine("TOTO");
return true;
}
return false;
}
}
}
|
|
|
|
|
Can i demo above program?
|
|
|
|
|
hi..
I am using .net ver 1.1(VS 2003),i need to call a web method asynchrously can any body provide some help...
pls provide some link which i can follow
|
|
|
|
|
This article on Asynchronous Method Invocation[^] may help you.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I want to set a string variable and use that to call a method.
E.g: Instead of calling Example.Test1, Example.Test2 etc, I want to just say call Example.Varable, and depending on what the user has selected from the form, it calls that method.
Any ideas how i would do this?, as i dont want to use lots of different if/case conditions as there is ALOT of different methods i want to set which the user will enter.
Regards,
Gareth.
|
|
|
|
|
Hi,
Reflection is the answer. There are many articles about it on CP. This one[^] should be sufficient for you. The InvokeMember section should be what you are searching for.
Robert
|
|
|
|
|
Your a star Robert!
Regards,
Gareth.
|
|
|
|
|
The problem:
///////////////////////
Hi everyone.
I have to develop an MDI app and in the main window I want to put a sizable panel on the left (like Solution Explorer in VS).
So I created a SplitContainer (in which there is an other splitContainer) and set it vertical and "Dock = Left".
My problem is that while internal panels are sizable, the container itself isn't sizable (so it has the right border fixed) and it stands fixed in a portion of my main window.
How can i make the splitcontainer sizable? otherwise: is there a workaround (such as other controls instead of splitContainer)?
thanks!
///////////////////////
First suggestion - by salysle:
///////////////////////
Use two split container controls; drop one on the form and set its dock property to fill, then drop another one in the left hand panel of the first split container and set its dock property to fill also but set its orientation property to horizontal. The main container and the subordinate container will adjust to fill the window during use and in response to resizing the form. You can still adjust the size of the panels by moving the splitter bars up and down or left and right.
///////////////////////
Other suggestions?
///////////////////////
Hi, thanks for replying me.
I've already tried this way, but using 2 splitContainers and setting one with Dock = Fill, opening a child window of the MDI container this is not visible because it appears (hide) under the container.
the problem is that my application should have a left panel as described before, but the rest of the main window shoud not be tabbed (as VS), but free for child windows.
any other suggestions?
///////////////////////
|
|
|
|
|
If you want docking windows then google "docking windows +c#", there's an open source implementation used in #Develop which you could also use.
Sig cops got me...
|
|
|
|
|
thanks ed.poore
but i want to do something easy by myself.
any suggestions?
|
|
|
|
|
How about just using a panel as the container for your "docking" window and then add a splitter to the form. That way the rest of the form is available for the MDI windows.
Sig cops got me...
|
|
|
|
|
Great idea!!
in this days i will try!
thanks a lot!
|
|
|
|
|
hi,
suppose i have two forms. form1 and form2.
form1 have 5 text boxes with data and 1 button.
i want, when i click the button i get those data in the form 2 using Delegate.
xyz.
xzv
|
|
|
|
|
Explain?
Sig cops got me...
|
|
|
|
|
i can't get u..... i want the code. plz explain that.
xzv
|
|
|
|
|
onlybabla wrote: i can't get u
You didn't explain why you want to use a delegate very clearly (well that's being polite, unlike someone, you didn't actually explain at all).
onlybabla wrote: i want the code
Obviously. You might as well ask nicely for it, or be willing to pay for it.
onlybabla wrote: plz explain that.
You've been set a task / created a task yourself and you would like some code to accomplish a particular function, that is why you want the code. As you why you're being rude I cannot explain that.
Sig cops got me...
|
|
|
|
|
Why would you need a delegate? Why not simply call form2 with a query string, or use session variables?
|
|
|
|
|
i can't call session variables because i am telling about Windows applications. not web.
xzv
|
|
|
|