473,396 Members | 1,998 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,396 software developers and data experts.

Calling console app (dtexec) from windows service

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.ex e
2007-01-22 15:13:19,773 [4624] INFO DTExecServerLog [Execute:0] -
strDTExecPath: C:\...\Visual Studio
2005\Projects\Learning\Test\Test\bin\Debug\Test.ex e
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.

Jan 22 '07 #1
0 3440

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

Similar topics

1
by: Samuel R. Neff | last post by:
We're using a 3rd party C DLL in a project that we don't have source for. When we call the DLL from a console app everything works fine. However, when we call it from a Windows Service, the DLL...
3
by: Dean Slindee | last post by:
I have a exception handling class that could be called from either a windows project app or a console project app. Is there any way for this class to determine which type of app called it without...
0
by: han zhiyang | last post by:
I've just studied the "how to" web service and the async pattern in donnet.I make a test with these knowledges,but I got a strange result. Here is my test. 1.Write a simple "Add" service named...
3
by: JohnH | last post by:
Does any one now how to create a .net service thet when run from the command line with say a -D argument will run as a console app and be able to output to that console window. The same .exe would...
5
by: Jon Davis | last post by:
Is there such a thing as a Windows standard for killing a console app that is monitored by a System.Diagnostics.Process object? I'm hosting several C# console apps in a C# Windows service and...
1
by: Joe | last post by:
Is it possible? I have a 3rd party app which repeatedly calls a console app and in order to speed things up I thought it would be better to have the consoles functionality contained within a...
12
by: Dilip | last post by:
Hi All I have a server based C# console application. This application must hide its console window when its launched out on the field. So I dutifully P/Invoke'd FindWindow/ShowWindow...
15
by: =?Utf-8?B?VG9tIENvcmNvcmFu?= | last post by:
I've been led to believe by several articles, particularly Eric Gunnerson's C# Calling Code Dynamically, that calling a method dynamically through Reflection was much slower than through a...
1
by: samdediacre | last post by:
Hi all, I have developped a very simple Windows service that references a managed .NET dll. the code within the dll contains a static class to read/write data from registry. So the OnStart()...
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: 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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.