|
Hi all,
Actually i was looking for automatic background process to deliver mails if certain condition met in database so i posted a question last week and i received suggestion to create Windows services to do it.
Unfortunatly I never worked with windows services so i created a small service and installed it without any trouble. But i am not able to start it. When am trying to start its giving be alert box saying "This service has been started and stopped. Some service stop automatically if they have no work to do."
But i have created the service with timer to trigger every 30 sec to write an entry to a database table.
Looks like i cannot start the service at all. Also i tried to debug it but i could not find my service.exe in the list to attach since it is not running. {instead i found explorer.exe which is new and from the same path my service.exe exists. But physically explorer.exe is not existing in that folder)
please some one help me in fixing this. Am i missing something?
Thanks in advance
Renu
|
|
|
|
|
There is a few registry flags that controls how services are run. One of these options, I think, is to have the service run in its own process or as part of a system process (cant remember which one). If the service is set to run as part of this system process it will be loaded with LoadLibrary() and executed on a thread of this system service. I think thats why you cant see it. Search around for details of the registry entries assosiated with a service.
For debugging I always used __asm{int 3} in c++ to break into the debugger but you probably cant do that in .Net
Why dont you put something in your init routine that will cause an exception. Then windows will show you the unhandled exception dialog and give you the option to debug the process
Generally I think it is easier to develop your app as an exe and then convert it into a service once its all debuged and running.
|
|
|
|
|
It sounds like your Main routine is simply returning without registering with the service control manager (not calling System.ServiceProcess.ServiceBase.Run ) or that the service's OnStart method is simply quitting. I can see that a working service we have here is creating a new thread in OnStart to do its work. This is virtually required because the OnStart method is expected to return back to the SCM fairly quickly - otherwise the control application will report that the service failed to start.
To debug service startup, we add the following to the top of Main :
#if DEBUG
System.Diagnostics.Debugger.Launch();
#endif This causes the Just-in-Time debugging window to appear, asking you which instance/version of VS you want to debug with.
|
|
|
|
|
Hi,
You are 100% correct. The problem was service's OnStart was simply quiting without doing anything. So i created a new thread in Onstart and it does solved the problem. The service is running without any trouble. Also since it is running i can locate it in running process list to attach to debug.
Your suggestion solved both of my problems. Thank you so much for you both Mike and Josh. Thanks a lot for your timely help.
Renu
|
|
|
|
|
Does .NET support DDE? Can we build DDE Clients and Servers in .NET? If yes, can an unmanaged application written in VC++6 or VB 6 communicate with a managed application using DDE?
---
Hakuna-Matada
It means no worries for the rest of your days...
It's our problem free, Philosophy
|
|
|
|
|
This topic[^] suggests that it's not possible.
That said, you can probably use the API directly. In fact, this blog post[^] links to a project on GotDotNet.com called NDde[^] which wraps the DDEML library.
|
|
|
|
|
Hi,
Does anyone can help me?
I'm writing a c++ managed service in visual studio 2005 CLR template. I only created one thread with simple code in order to achieve a lightweight service as possible, but I noticed that the running service has about 7 or 8 Mbytes of memory.
What´s happening with the service that despite the user code, the skeleton of Visual Studio template allocates at least 7 Mbytes of memory!
How do I write a service with less than 3 Mbytes like "Windows Installer", in order to spend fewer memory resources?
thanks
|
|
|
|
|
Since your writing in Managed C++, you have the weight of the .NET CLR in there as well. That's about as small as your going to get.
If you want a smaller memory footprint, you'll have to use unmanaged C++.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Dave,
Thank you so much for your help.
Luis Coito
|
|
|
|
|
Hi can u tell me
i have a comm.dll file, and i want to use it in c#.net ;;;
when i add this dll through reference i get an error means i cannot add the dll,
please tell me how to use this comm.dill file,,,
its comm dll file
thanks in advance
hello
|
|
|
|
|
You can only set a reference to a COM-based .DLL. If it's a libary .DLL, all you have to do is P/Invoke the functions you want to use.
Platform Invoke Tutorial[^] on MSDN.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks i have got that and now i can access the function from this dll, and can open, close and get values from the comm but only using the functions in this dll..
but now the problem is i cannot fire datareceived event on the com port which i assign
to open method of this dll,,
int hc = OpenCommPort("COM1", 9600);///method from dll which open the com1
int rtt = ReadValue(hc);///mehtod from dll
now i do the following
sp = new SerialPort("COM1",9600);
sp.DataReceived += new SerialDataReceivedEventHandler(method);
if (sp.isopen);
{
show ("Open");//but here it shows that com port is closed ,, so i cannot manage
data received event handler for this com port ,,
}
please tell me in the scenario what shud i do ?
void method()
{
// this method shud be called when the ( int rtt = ReadValue(hc);)
is called...but it does not , even i get an error when i try to open
sp using sp.open();
aftehr when i have called the dll function
int hc = OpenCommPort("COM1", 9600)
so please tell me how to create a handler for the situation ,, means the port which
i assign to the dll method opencommport there shud be a handler for that
thakns in advance
}
hello
|
|
|
|
|
|
What is Ajax. Can i get a sample program demonstrating Ajax?
Maddy
|
|
|
|
|
|
Hi can u tell me
How cam we play flash files (swf) in c#.net
thaks in advance
hello
|
|
|
|
|
Add a shockwave flash control to the form, pass the path to the swf file to it.
|
|
|
|
|
thanks
but it says that active x component is not registered properly,, and i cant register it via svr 32 command
wat to do ?
again thanks in advance
hello
|
|
|
|
|
Reinstall the Flash/Shockwave player. I think their both in one application now. Download[^]
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
thanks you very much
i have installed it and i can drag and drop it on my window form ,,
but can i attatch a flash file with it to play ,,,
coz i did not find any property like that in this active x control
thanks in advance
hello
|
|
|
|
|
That I don't know. You'll have to get that kind of help from Adobe. I've never put a flash component on any form so I don't know what it's object model looks like.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I simply cannot get the form designer to save my property value in the .designer.cs file:
<br />
<br />
public partial class MyClass: UserControl<br />
{<br />
[Browsable(true)]<br />
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]<br />
public string Text<br />
{<br />
get<br />
{<br />
return _text;<br />
}<br />
set<br />
{<br />
_text = value;<br />
Invalidate();<br />
}<br />
}<br />
}<br />
Nothing is saved. Any ideas? VS 2005, .NET 2.0
|
|
|
|
|
Seems it's the name's fault. Anything other than "Text" works just fine. Will investigate further.
|
|
|
|
|
Found an explanation:
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/msg/e3089235cb94cfe5?hl=en
Really bothersome, since that is probably one of the most often used property names.
|
|
|
|
|
Hi All,
i am very new to .NET. Can anyone explain me the entire process of a source code getting executed. How CLR works? Wat is metadata? And other basic things about .NET Framework and its components.
If not, can anyone suggest me a good article about .NET framework that covers basic things abt it?
|
|
|
|