PC Review


Reply
Thread Tools Rate Thread

Calling console app (dtexec) from windows service

 
 
asadikhan@gmail.com
Guest
Posts: n/a
 
      22nd Jan 2007
I need to call a console app (dtexec) from a windows service in a
client/server architecture. I have the application setup so that the
client application is called with a package name, which makes a call to
a dll on the remote server. I have read up on this on the web and I
know that you can't run a GUI app from within windows service, but
apparently console apps are ok. I am trying exactly that but it's not
working. Here is my code:

Server side:

public bool Execute(string strPackageName)
{
log.Info("strDTExecPath: " + strDTExecPath);
log.Info("strPackageName: " + strPackageName);
try
{
log.Info("Starting");
System.Diagnostics.Process.Start(strDTExecPath,
strPackageName);
log.Info("Finishing");
}
catch (Exception ex)
{
log.Error(ex.ToString());
return false;
}
return true;
}

Client Side:

static void Main(string[] args)
{
try
{
string strURLRemoteClass =
ConfigurationSettings.AppSettings["URLRemoteClass"];
string strPackageName = args[0].Trim();
if (strPackageName.Length <= 0)
{
log.Info("No package name provided in the
arguments.");
return;
}
// Step 1: Register a TCP client channel
TcpClientChannel channel = new TcpClientChannel();
ChannelServices.RegisterChannel(channel);
// Step 2: Register the remote class as a valid type
// in the client's application domain
RemotingConfiguration.RegisterWellKnownClientType(
typeof(DTExec),
strURLRemoteClass);
// Step 3: Instantiate the remote class
objDTExec = new DTExec();

if (objDTExec.Execute(strPackageName))
log.Info("Success");
else
log.Info("Failure");
}
catch (Exception ex)
{
log.Info(ex.ToString());
}
}

No errors are logged on either side. In the server log file I get this:


2007-01-22 15:13:19,763 [4624] INFO DTExecServerLog [.ctor:0] -
strDTExecPath: C:\...\Visual Studio
2005\Projects\Learning\Test\Test\bin\Debug\Test.exe
2007-01-22 15:13:19,773 [4624] INFO DTExecServerLog [Execute:0] -
strDTExecPath: C:\...\Visual Studio
2005\Projects\Learning\Test\Test\bin\Debug\Test.exe
2007-01-22 15:13:19,773 [4624] INFO DTExecServerLog [Execute:0] -
strPackageName: C:\foo.txt
2007-01-22 15:13:19,773 [4624] INFO DTExecServerLog [Execute:0] -
Starting
2007-01-22 15:13:19,844 [4624] INFO DTExecServerLog [Execute:0] -
Finishing


Any ideas as to what I am doing wrong?

Any comments on how we can run DTEXEC remotely without having to
install anything additional on the workstation are also welcomed.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VB 6 app calling C# windows service =?Utf-8?B?Y3liZXJzdHJpa2U=?= Microsoft Dot NET 1 3rd Jun 2005 10:02 AM
Windows service with console =?Utf-8?B?Um9iIFdoaXRl?= Microsoft Dot NET Framework 3 12th May 2005 09:55 AM
Calling a static method from within a C# windows service causes the service to hang? Microsoft C# .NET 3 15th Mar 2004 03:03 PM
Architecture: Web Service as Management Console for Windows Service Vincent Mouton Microsoft Dot NET Framework 0 10th Nov 2003 10:00 AM
Calling a GUI in windows service Gary Microsoft Dot NET Framework 1 27th Aug 2003 09:09 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:14 PM.