pass parameter from windows service to windows application interna

V

vishruth

Hi,

I have 2 applications running, one Windows application project and the other
windows services project.
I want to call my Windows application in my windows services.
I want to run them as seperate process.
If my windows application starts running,only if it completes fully,
then my windows services should continue its execution.

My main process is Windows service.
I want to pass Windows services,MakeZip function parameters to my Windows
Application
MakeZip(string zipname,string[] files)
I want to pass this function parameters to my Windows application.
How can I do this?Only then I know my windows application will run
internally as seperate process
without disturbing windows services.I think we have to use command line
arguments,
but I dont know how to use it.

Here is my code for Windows service and windows application.
Please help me
1. how to create process ie. how to run windows application as seperate
process
inside windows services code.I want windows service to run as seperate
process and
Windows application to run as seperate process.
2. how to pass parameters from windows services project to windows
application project.


//My Code starts here:


Windows Services:

MakeZip(string zipname,string[] files)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName="c:\\programfiles\\visualstudioprojects\\WindowsAppZip.exe";
proc.Start();
MessageBox.Show("Zipped Done");
}


WindowsAppZip:

using Xceed.Compression;

using Xceed.FileSystem;

using Xceed.Zip;

private void button2_Click(object sender, System.EventArgs e)
{
// In my windows services zipname and files have got values.
//I want to call them here in this application from Windows service
MakeZip(string zipname,string[] files) // calling MakeZipFile Function Here
}


Xceed.Zip.Licenser.LicenseKey = "ZINxx-xxxxx-xxxxx-xxxx";

public int MakeZip(string zipFileName, string[] filesToComp)
{
int retVal = 0;
try
{
ZipArchive zip = new ZipArchive( new DiskFile( zipFileName ) );
try
{
zip.BeginUpdate();
foreach( string file in filesToComp )
{
DiskFile fileToZip = new DiskFile( file );
fileToZip.CopyTo( zip, true );
++retVal;
}
}
finally
{
zip.EndUpdate();
}
}

catch(Exception exec)
{
throw new ZipException(exec.Message);
}
finally
{
}
return retVal;
}
}

}
 
N

Nicholas Paldino [.NET/C# MVP]

Why not have the service perform the zip operation?

Regardless, you will need to use remoting for this. You will have to
have the windows application contact the server over a remoting channel
(using Remoting, or Windows Communications Foundation), and then store a
reference to an object derived from MarshalByRefObject that the windows
application passes to the server (or if using WCF, you would pass a callback
interface which would be called by the server).

Then, you would make calls in the service to the client through the
reference passed to it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

vishruth said:
Hi,

I have 2 applications running, one Windows application project and the
other
windows services project.
I want to call my Windows application in my windows services.
I want to run them as seperate process.
If my windows application starts running,only if it completes fully,
then my windows services should continue its execution.

My main process is Windows service.
I want to pass Windows services,MakeZip function parameters to my Windows
Application
MakeZip(string zipname,string[] files)
I want to pass this function parameters to my Windows application.
How can I do this?Only then I know my windows application will run
internally as seperate process
without disturbing windows services.I think we have to use command line
arguments,
but I dont know how to use it.

Here is my code for Windows service and windows application.
Please help me
1. how to create process ie. how to run windows application as seperate
process
inside windows services code.I want windows service to run as seperate
process and
Windows application to run as seperate process.
2. how to pass parameters from windows services project to windows
application project.


//My Code starts here:


Windows Services:

MakeZip(string zipname,string[] files)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName="c:\\programfiles\\visualstudioprojects\\WindowsAppZip.exe";
proc.Start();
MessageBox.Show("Zipped Done");
}


WindowsAppZip:

using Xceed.Compression;

using Xceed.FileSystem;

using Xceed.Zip;

private void button2_Click(object sender, System.EventArgs e)
{
// In my windows services zipname and files have got values.
//I want to call them here in this application from Windows service
MakeZip(string zipname,string[] files) // calling MakeZipFile Function
Here
}


Xceed.Zip.Licenser.LicenseKey = "ZINxx-xxxxx-xxxxx-xxxx";

public int MakeZip(string zipFileName, string[] filesToComp)
{
int retVal = 0;
try
{
ZipArchive zip = new ZipArchive( new DiskFile( zipFileName ) );
try
{
zip.BeginUpdate();
foreach( string file in filesToComp )
{
DiskFile fileToZip = new DiskFile( file );
fileToZip.CopyTo( zip, true );
++retVal;
}
}
finally
{
zip.EndUpdate();
}
}

catch(Exception exec)
{
throw new ZipException(exec.Message);
}
finally
{
}
return retVal;
}
}

}
 
V

vishruth

Can u please provide me the snippet of code (related to my task) to perform
this task.
I have absolutely no idea about remoting or WCF .
Thank u for ur help.
Vishruth

Nicholas Paldino said:
Why not have the service perform the zip operation?

Regardless, you will need to use remoting for this. You will have to
have the windows application contact the server over a remoting channel
(using Remoting, or Windows Communications Foundation), and then store a
reference to an object derived from MarshalByRefObject that the windows
application passes to the server (or if using WCF, you would pass a callback
interface which would be called by the server).

Then, you would make calls in the service to the client through the
reference passed to it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

vishruth said:
Hi,

I have 2 applications running, one Windows application project and the
other
windows services project.
I want to call my Windows application in my windows services.
I want to run them as seperate process.
If my windows application starts running,only if it completes fully,
then my windows services should continue its execution.

My main process is Windows service.
I want to pass Windows services,MakeZip function parameters to my Windows
Application
MakeZip(string zipname,string[] files)
I want to pass this function parameters to my Windows application.
How can I do this?Only then I know my windows application will run
internally as seperate process
without disturbing windows services.I think we have to use command line
arguments,
but I dont know how to use it.

Here is my code for Windows service and windows application.
Please help me
1. how to create process ie. how to run windows application as seperate
process
inside windows services code.I want windows service to run as seperate
process and
Windows application to run as seperate process.
2. how to pass parameters from windows services project to windows
application project.


//My Code starts here:


Windows Services:

MakeZip(string zipname,string[] files)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName="c:\\programfiles\\visualstudioprojects\\WindowsAppZip.exe";
proc.Start();
MessageBox.Show("Zipped Done");
}


WindowsAppZip:

using Xceed.Compression;

using Xceed.FileSystem;

using Xceed.Zip;

private void button2_Click(object sender, System.EventArgs e)
{
// In my windows services zipname and files have got values.
//I want to call them here in this application from Windows service
MakeZip(string zipname,string[] files) // calling MakeZipFile Function
Here
}


Xceed.Zip.Licenser.LicenseKey = "ZINxx-xxxxx-xxxxx-xxxx";

public int MakeZip(string zipFileName, string[] filesToComp)
{
int retVal = 0;
try
{
ZipArchive zip = new ZipArchive( new DiskFile( zipFileName ) );
try
{
zip.BeginUpdate();
foreach( string file in filesToComp )
{
DiskFile fileToZip = new DiskFile( file );
fileToZip.CopyTo( zip, true );
++retVal;
}
}
finally
{
zip.EndUpdate();
}
}

catch(Exception exec)
{
throw new ZipException(exec.Message);
}
finally
{
}
return retVal;
}
}

}
 
N

Nicholas Paldino [.NET/C# MVP]

If you aren't familiar with remoting or WCF, I suggest looking at the
MSDN documentation for it, as there is much more to it than just a simple
code snippet could explain.

A google search for remoting or WCF (short for Windows Communications
Foundation) should provide some useful links.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

vishruth said:
Can u please provide me the snippet of code (related to my task) to
perform
this task.
I have absolutely no idea about remoting or WCF .
Thank u for ur help.
Vishruth

Nicholas Paldino said:
Why not have the service perform the zip operation?

Regardless, you will need to use remoting for this. You will have to
have the windows application contact the server over a remoting channel
(using Remoting, or Windows Communications Foundation), and then store a
reference to an object derived from MarshalByRefObject that the windows
application passes to the server (or if using WCF, you would pass a
callback
interface which would be called by the server).

Then, you would make calls in the service to the client through the
reference passed to it.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

vishruth said:
Hi,

I have 2 applications running, one Windows application project and the
other
windows services project.
I want to call my Windows application in my windows services.
I want to run them as seperate process.
If my windows application starts running,only if it completes fully,
then my windows services should continue its execution.

My main process is Windows service.
I want to pass Windows services,MakeZip function parameters to my
Windows
Application
MakeZip(string zipname,string[] files)
I want to pass this function parameters to my Windows application.
How can I do this?Only then I know my windows application will run
internally as seperate process
without disturbing windows services.I think we have to use command line
arguments,
but I dont know how to use it.

Here is my code for Windows service and windows application.
Please help me
1. how to create process ie. how to run windows application as seperate
process
inside windows services code.I want windows service to run as
seperate
process and
Windows application to run as seperate process.
2. how to pass parameters from windows services project to windows
application project.


//My Code starts here:


Windows Services:

MakeZip(string zipname,string[] files)
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName="c:\\programfiles\\visualstudioprojects\\WindowsAppZip.exe";
proc.Start();
MessageBox.Show("Zipped Done");
}


WindowsAppZip:

using Xceed.Compression;

using Xceed.FileSystem;

using Xceed.Zip;

private void button2_Click(object sender, System.EventArgs e)
{
// In my windows services zipname and files have got values.
//I want to call them here in this application from Windows service
MakeZip(string zipname,string[] files) // calling MakeZipFile Function
Here
}


Xceed.Zip.Licenser.LicenseKey = "ZINxx-xxxxx-xxxxx-xxxx";

public int MakeZip(string zipFileName, string[] filesToComp)
{
int retVal = 0;
try
{
ZipArchive zip = new ZipArchive( new DiskFile( zipFileName ) );
try
{
zip.BeginUpdate();
foreach( string file in filesToComp )
{
DiskFile fileToZip = new DiskFile( file );
fileToZip.CopyTo( zip, true );
++retVal;
}
}
finally
{
zip.EndUpdate();
}
}

catch(Exception exec)
{
throw new ZipException(exec.Message);
}
finally
{
}
return retVal;
}
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top