Hi all,
I created a Minimal Windows Service Program in Visual Studio.NET VC# using
the Wizard...i just added the MessageBox Display in OnStart() function and my
service is installed properly...but when i started the Service it display
that "Local Service started and stopped , Serivces should have Log Support
and Alerts Isssued"..
what is this error??...am running Windows XP Home Edition,
i have given the AccountType as "LocalService", i tried with everything
excpet with User...i no need to run as User...
i would be happy if anyone could help me sort out this ...
with regards,
C.C.Chakkaradee p 12 4853
The errors is that you should not show a message box from a service.
Services are meant to run in the background without any user interaction
requirements.
Willy.
"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:12******** *************** ***********@mic rosoft.com... Hi all,
I created a Minimal Windows Service Program in Visual Studio.NET VC# using the Wizard...i just added the MessageBox Display in OnStart() function and my service is installed properly...but when i started the Service it display that "Local Service started and stopped , Serivces should have Log Support and Alerts Isssued"..
what is this error??...am running Windows XP Home Edition,
i have given the AccountType as "LocalService", i tried with everything excpet with User...i no need to run as User...
i would be happy if anyone could help me sort out this ...
with regards, C.C.Chakkaradee p
Hi Willy,
so then how to check it out whether it is running or not..and is Socket
Communication possible in Services.....th at is,..my service should act as a
Multithreaded Server monitoring a Port Number and if any informations come to
the port it should accept the sockets and exeute something so that the
Service has completed it's job...
am a newbie to to this Service...
with regards,
C.C.Chakkaradee p
"Willy Denoyette [MVP]" wrote: The errors is that you should not show a message box from a service. Services are meant to run in the background without any user interaction requirements.
Willy.
"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message news:12******** *************** ***********@mic rosoft.com... Hi all,
I created a Minimal Windows Service Program in Visual Studio.NET VC# using the Wizard...i just added the MessageBox Display in OnStart() function and my service is installed properly...but when i started the Service it display that "Local Service started and stopped , Serivces should have Log Support and Alerts Isssued"..
what is this error??...am running Windows XP Home Edition,
i have given the AccountType as "LocalService", i tried with everything excpet with User...i no need to run as User...
i would be happy if anyone could help me sort out this ...
with regards, C.C.Chakkaradee p
Socket communications are no issue. But you should be aware that services
are (should be) running in a restricted security context:
- They should not assume the presence of an interactive desktop nor an
interactive user (logon session).
- For security reasons, they should run with the least privileges possible
(run as NetworkService or LocalService).
Running as LocalSystem gives the service high privileges on the local system
but no access to remote system resources, it's the only account that enables
a service to interact with the desktop (to enable this - run services applet
and check/enable this property).
While it's possible to enable this option for quick and dirty debugging, I
would suggest you use one of the other facilities offered by .NET for
debugging and tracing (write to log file or eventlog, output to debugger
window etc.).
Willy.
"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:E1******** *************** ***********@mic rosoft.com... Hi Willy,
so then how to check it out whether it is running or not..and is Socket Communication possible in Services.....th at is,..my service should act as a Multithreaded Server monitoring a Port Number and if any informations come to the port it should accept the sockets and exeute something so that the Service has completed it's job...
am a newbie to to this Service...
with regards, C.C.Chakkaradee p
"Willy Denoyette [MVP]" wrote:
The errors is that you should not show a message box from a service. Services are meant to run in the background without any user interaction requirements.
Willy.
"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message news:12******** *************** ***********@mic rosoft.com... > Hi all, > > I created a Minimal Windows Service Program in Visual Studio.NET VC# > using > the Wizard...i just added the MessageBox Display in OnStart() function > and > my > service is installed properly...but when i started the Service it > display > that "Local Service started and stopped , Serivces should have Log > Support > and Alerts Isssued".. > > what is this error??...am running Windows XP Home Edition, > > i have given the AccountType as "LocalService", i tried with everything > excpet with User...i no need to run as User... > > i would be happy if anyone could help me sort out this ... > > with regards, > C.C.Chakkaradee p
Hi Willy,
so u mean to say that i can accept a socket and receive messages but i cant
send messages back to the client??
with regards,
C.C.Chakkaradee p
"Willy Denoyette [MVP]" wrote: Socket communications are no issue. But you should be aware that services are (should be) running in a restricted security context: - They should not assume the presence of an interactive desktop nor an interactive user (logon session). - For security reasons, they should run with the least privileges possible (run as NetworkService or LocalService). Running as LocalSystem gives the service high privileges on the local system but no access to remote system resources, it's the only account that enables a service to interact with the desktop (to enable this - run services applet and check/enable this property). While it's possible to enable this option for quick and dirty debugging, I would suggest you use one of the other facilities offered by .NET for debugging and tracing (write to log file or eventlog, output to debugger window etc.).
Willy.
"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message news:E1******** *************** ***********@mic rosoft.com... Hi Willy,
so then how to check it out whether it is running or not..and is Socket Communication possible in Services.....th at is,..my service should act as a Multithreaded Server monitoring a Port Number and if any informations come to the port it should accept the sockets and exeute something so that the Service has completed it's job...
am a newbie to to this Service...
with regards, C.C.Chakkaradee p
"Willy Denoyette [MVP]" wrote:
The errors is that you should not show a message box from a service. Services are meant to run in the background without any user interaction requirements.
Willy.
"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message news:12******** *************** ***********@mic rosoft.com... > Hi all, > > I created a Minimal Windows Service Program in Visual Studio.NET VC# > using > the Wizard...i just added the MessageBox Display in OnStart() function > and > my > service is installed properly...but when i started the Service it > display > that "Local Service started and stopped , Serivces should have Log > Support > and Alerts Isssued".. > > what is this error??...am running Windows XP Home Edition, > > i have given the AccountType as "LocalService", i tried with everything > excpet with User...i no need to run as User... > > i would be happy if anyone could help me sort out this ... > > with regards, > C.C.Chakkaradee p
"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:1E******** *************** ***********@mic rosoft.com... Hi Willy,
so u mean to say that i can accept a socket and receive messages but i cant send messages back to the client??
No, I said Sockets are no problem.
Willy.
hi,
so then Sockets are not issue...hmm...n ice to hear...so i can just create
Sockets using TcpListener and accept TcpClients,rite ?.....and how to check
for OnStart() function...by storing some informations in files???
with regards,
C.C.Chakkaradee p
"Willy Denoyette [MVP]" wrote: "Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message news:1E******** *************** ***********@mic rosoft.com... Hi Willy,
so u mean to say that i can accept a socket and receive messages but i cant send messages back to the client??
No, I said Sockets are no problem. Willy.
"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> wrote in message
news:DF******** *************** ***********@mic rosoft.com... hi,
so then Sockets are not issue...hmm...n ice to hear...so i can just create Sockets using TcpListener and accept TcpClients,rite ?.....and how to check for OnStart() function...by storing some informations in files???
Just write a message to the eventlog.
Willy.
hi willy ,
here is my code for Service...
/*********Servic e OnStart( ) function starts here*********** ***********/
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
System.Net.IPAd dress localAdd=System .Net.IPAddress. Parse("127.0.0. 1");
const int portNumber = 3000;
TcpListener tcpListener = new TcpListener(loc alAdd,portNumbe r);
tcpListener.Sta rt();
//try
{
//Accept the pending client connection and return a TcpClient initialized
for communication.
TcpClient tcpClient = tcpListener.Acc eptTcpClient();
NetworkStream networkStream =
tcpClient.GetSt ream();
string responseString = "You have successfully connected to me";
Byte[] sendBytes = Encoding.ASCII. GetBytes(respon seString);
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h);
tcpClient.Close ();
tcpListener.Sto p();
}
}
/*********Servic e OnStart( ) function ends here*********** ***********/
I tried with evry Account....when i start the service,it is taking much time
and then finally tells that the servie cannot be installed becoz it is out of
time.....what is my error???
The client progrm is here...
/*********Client Program Starts here*********** ***********/
static void Main(string[] args)
{
TcpClient tcpClient = new TcpClient();
try {
tcpClient.Conne ct("localhost" , 3000);
NetworkStream networkStream = tcpClient.GetSt ream();
if(networkStrea m.CanWrite && networkStream.C anRead){
// Does a simple write.
Byte[] sendBytes = Encoding.ASCII. GetBytes("Is anybody there");
networkStream.W rite(sendBytes, 0, sendBytes.Lengt h);
// Reads the NetworkStream into a byte buffer.
byte[] bytes = new byte[tcpClient.Recei veBufferSize];
networkStream.R ead(bytes, 0, (int) tcpClient.Recei veBufferSize);
// Returns the data received from the host to the console.
string returndata = Encoding.ASCII. GetString(bytes );
Console.WriteLi ne("This is what the host returned to you: " +
returndata);
}
else if (!networkStream .CanRead)
{
Console.WriteLi ne("You can not write data to this stream");
tcpClient.Close ();
}
else if (!networkStream .CanWrite)
{
Console.WriteLi ne("You can not read data from this stream");
tcpClient.Close ();
}
}
catch (Exception e )
{
Console.WriteLi ne(e.ToString() );
}
}
/*********Client Program ends here*********** ***********/
The Server and Client Samples were taken from MSDN only.....
what would be the problem...
with regards,
C.C.Chakkaradee p
"Chakkarade ep" <Ch**********@d iscussions.micr osoft.com> ha scritto nel
messaggio news:F5******** *************** ***********@mic rosoft.com... hi willy ,
here is my code for Service...
/*********Servic e OnStart( ) function starts here*********** ***********/ protected override void OnStart(string[] args) { // TODO: Add code here to start your service. System.Net.IPAd dress localAdd=System .Net.IPAddress. Parse("127.0.0. 1"); const int portNumber = 3000; TcpListener tcpListener = new TcpListener(loc alAdd,portNumbe r); tcpListener.Sta rt(); //try { //Accept the pending client connection and return a TcpClient initialized for communication. TcpClient tcpClient = tcpListener.Acc eptTcpClient(); NetworkStream networkStream = tcpClient.GetSt ream(); string responseString = "You have successfully connected to me";
Byte[] sendBytes = Encoding.ASCII. GetBytes(respon seString); networkStream.W rite(sendBytes, 0, sendBytes.Lengt h);
tcpClient.Close (); tcpListener.Sto p();
} } /*********Servic e OnStart( ) function ends here*********** ***********/
I tried with evry Account....when i start the service,it is taking much time and then finally tells that the servie cannot be installed becoz it is out of time.....what is my error???
This code is correct, but it can't work; the SCM calls the OnStart()
function and expects it to return, or it will report the timout you're
experiencing; so you can do only initializations there, not your main
processing (i.e. waiting for connections). You'll have to run the service on
a different thread than the one who calls OnStart. You have two choiches
here: spawn the worker thread manually and have it run the same code you
tried to run inside OnStart(), or use async sockets..
Massimo This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Stefan Hinz |
last post by:
Degan,
jumping in to try and solve some problems that look pretty obvious to
me ...
> #options for default service (mysqld2)
> (mysqld2)
It should be , not (mysqld2).
|
by: Bill Sonia |
last post by:
I've written a Windows Service to send e-mails on events like OnStart,
OnStop, OnShutDown using System.Web.Mail. It works for everything but
OnShutdown. My guess is that for OnShutDown, once my send mail code is
executed, other necessary Windows Services have been terminated before
it can actually send the mail. I've updated my...
|
by: illegal.prime |
last post by:
Hi all, I have a service that needs to start a regular windows
application.
I'm running the service as ServiceAccount.LocalSystem.
But, when it starts the process (using Process.Start) the GUI for the
application doesn't appear - however, I can see the process in the
TaskManager.
Now, feel free to mention that starting a regular...
|
by: =?Utf-8?B?dmlzaHJ1dGg=?= |
last post by:
This code works fine in Windows Application.
In Windows Application, I am able to zip the image files properly and it
totally contains 900MB
My problem is the same code which I used in my Windows Application,
does not work while I run it with Windows services.
In my Windows application I am able to zip the whole 900Mb without any
problems,...
|
by: =?Utf-8?B?dmlzaHJ1dGg=?= |
last post by:
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...
| |
by: =?Utf-8?B?dmlzaHJ1dGg=?= |
last post by:
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...
|
by: dm3281 |
last post by:
I'm really starting to hate writing services -- or trying to, anyway.
Why do I need to rename my project to the service name?
Why do I need to set the "ServiceName" property to my service name?
Why do I need to set a property within my code to the service name?
Are all these required or am I just doing this for consistency purposes?
|
by: AmberJain |
last post by:
Windows Autorun FAQs: Overview
NOTE- This complete article on "Windows Autorun FAQs" applies theoretically to all Windows NT-based OSes till Windows Vista (and probably Vista's successors too). Much of the contents of this article are tested on Windows XP professional SP2 by the author. Some instances of this article may be altogether...
|
by: AmberJain |
last post by:
Windows Autorun FAQs: List of autostart locations
Linked from the Original article- "Windows Autorun FAQs: Description".
Que: Can you list all the autostart locations for windows?
Ans: Here is a comprehensive list of all autostart locations for Windows OSes:
NOTE : These are some abbreviations used in this list. Please note them...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |