473,386 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Controle one application from another

Hi

I have a problem, I need to controle one app from another application. If I
press a button in app1 then somthing is going to happend in app2.

I hope somone understands what I mean.

Thanks
- Fredrik
Nov 16 '05 #1
3 1203
Fredrik Andersson wrote:
I have a problem, I need to controle one app from another application. If I
press a button in app1 then somthing is going to happend in app2.


I think remoting will be right for you. If you decide to do so, follow
these instructions:

1.

Create a interface, that contains all the methods that app2 shoud be
able to do.

2.

In app2, declare these using's and this object:

using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;

....

private IChannel channel1 = null;

At the time, where the application should start "listening" to commands,
insert about this code (customize port number and service name):

channel1 = new TcpChannel(12345);
ChannelServices.RegisterChannel(channel1);
RemotingServices.Marshal(this,"MyApp2.rem");

3.

In app1, simply add this code (again, change port number and service
name as you did above, and the name of the interface (IYourInterface)):

string strConnectionString = "tcp://" + Host + ":12345/MyApp2.rem";
TcpChannel channel = new TcpChannel();
ChannelServices.RegisterChannel(channel);

IYourInterface x =
(IYourInterface)Activator.GetObject(typeof(IYourIn terface),strConnectionString);
if (x==null)
{
// something went wrong
}
else
{
// call any methods here
}

May be in your case it's clever to define "x" (please use a good name
for this object) at class level, run the activation at start up of your
application and in the button's click event, check whether x is null or
not and do the things you want.

HTH,

Michael

--
http://www.mkcs.at/
The specified e-mail-address is valid and will be read.
Nov 16 '05 #2
Hi,

You may need to define a protocol to send commands to the target
application. if you give more details a better solution can be proposed.
cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"Fredrik Andersson" <fr****@telia.com> wrote in message
news:uS*************@TK2MSFTNGP09.phx.gbl...
Hi

I have a problem, I need to controle one app from another application. If I press a button in app1 then somthing is going to happend in app2.

I hope somone understands what I mean.

Thanks
- Fredrik

Nov 16 '05 #3
Thanks Michael

Is there no posibility to do app2 as a com object in some way. It's just a
fiew of the functions i need to use and I know that both of them will be on
the same computer

"Michael Kremser" <mk************@yahoo.de> wrote in message
news:eb**************@TK2MSFTNGP15.phx.gbl...
Fredrik Andersson wrote:
I have a problem, I need to controle one app from another application. If I press a button in app1 then somthing is going to happend in app2.
I think remoting will be right for you. If you decide to do so, follow
these instructions:

1.

Create a interface, that contains all the methods that app2 shoud be
able to do.

2.

In app2, declare these using's and this object:

using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;

...

private IChannel channel1 = null;

At the time, where the application should start "listening" to commands,
insert about this code (customize port number and service name):

channel1 = new TcpChannel(12345);
ChannelServices.RegisterChannel(channel1);
RemotingServices.Marshal(this,"MyApp2.rem");

3.

In app1, simply add this code (again, change port number and service
name as you did above, and the name of the interface (IYourInterface)):

string strConnectionString = "tcp://" + Host + ":12345/MyApp2.rem";
TcpChannel channel = new TcpChannel();
ChannelServices.RegisterChannel(channel);

IYourInterface x =

(IYourInterface)Activator.GetObject(typeof(IYourIn terface),strConnectionStri
ng); if (x==null)
{
// something went wrong
}
else
{
// call any methods here
}

May be in your case it's clever to define "x" (please use a good name
for this object) at class level, run the activation at start up of your
application and in the button's click event, check whether x is null or
not and do the things you want.

HTH,

Michael

--
http://www.mkcs.at/
The specified e-mail-address is valid and will be read.

Nov 16 '05 #4

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

Similar topics

1
by: Gabriel Lozano-Morán | last post by:
First of all sorry for the cross-posting but I am not sure wether this belongs under internationalization or just general. Environment: Visual Studio .NET 2003 Problem: Newly added and...
0
by: Filips Benoit | last post by:
A particular form - always the same - sometimes becomes corrupt after saving. Error msg = The expression On Open you entered as the event property settings produced the following error: A...
11
by: Timothy Shih | last post by:
Hi, I am having a freezing issue with my application. My application serves several remotable objects, all of which must be initialized before their use. Furthermore, some of them depend on each...
1
by: | last post by:
hi, can some one tell me snip code to get reference to web user controle (.ascx form) aspx "table" and its rows & cells. regards Sam.
6
by: orekin | last post by:
Hi There I have been trying to come to grips with Application.Run(), Application.Exit() and the Message Pump and I would really appreciate some feedback on the following questions .. There are...
5
by: Amar | last post by:
Hi All, In my application I want to disable my controle keys to save copying and taking screen shots of the my page.Please help me. Thanks Amar
6
seshu
by: seshu | last post by:
Hi Everybody i want to know the name of the controle which i see in my vb.net ie non other the tool box there i am able to see five tabs in that but what is the name of that...
4
by: Dave | last post by:
I have a global.asax file with Application_Start defined and create some static data there and in another module used in the asp.net application and I realize that static data is shared amongst...
1
by: chanchalgupta | last post by:
Hi, Is there anyone to help me for making user controle. Thanks in advance
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.