|
Dear Mark,
I'm using Visual C# Express 2005 and i can't find the process debugger on my debug tab. But i can present you the code i'm using:
using System;
using System.ServiceProcess;
using System.Threading;
using System.Windows.Forms;
using System.Diagnostics;
using Microsoft.Win32;
using System.ComponentModel;
using System.Configuration.Install;
using System.Net.Mail;
namespace SimpleServiceCs
{
public class SimpleService : ServiceBase
{
static void Main(string[] args)
{
ServiceBase.Run(new SimpleService());
}
protected override void OnStart(string[] args)
{
EventLog.WriteEntry("SimpleService", "Starting SimpleService");
new Thread(RunMessagePump).Start();
}
void RunMessagePump()
{
EventLog.WriteEntry("SimpleService.MessagePump", "Starting SimpleService Message Pump");
Application.Run(new HiddenForm());
}
protected override void OnStop()
{
Application.Exit();
}
}
public partial class HiddenForm : Form
{
public HiddenForm()
{
InitializeComponent();
}
private void HiddenForm_Load(object sender, EventArgs e)
{
SystemEvents.SessionEnding += new SessionEndingEventHandler(SystemEvents_SessionEnding);
}
private void HiddenForm_FormClosing(object sender, FormClosingEventArgs e)
{
SystemEvents.SessionEnding -= new SessionEndingEventHandler(SystemEvents_SessionEnding);
}
private void SystemEvents_SessionEnding(object sender, EventArgs e)
{
EventLog.WriteEntry("System Logoff or System Shutdown");
SendEMail("Your System is being Logged Off or Shutdown!");
}
private void SendEmail(string Warning){
}
}
partial class HiddenForm
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.SuspendLayout();
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(0, 0);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "HiddenForm";
this.Text = "HiddenForm";
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.Load += new System.EventHandler(this.HiddenForm_Load);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HiddenForm_FormClosing);
this.ResumeLayout(false);
}
}
[RunInstaller(true)]
public class SimpleInstaller : Installer
{
private ServiceInstaller serviceInstaller;
private ServiceProcessInstaller processInstaller;
public SimpleInstaller()
{
processInstaller = new ServiceProcessInstaller();
serviceInstaller = new ServiceInstaller();
processInstaller.Account = ServiceAccount.LocalSystem;
serviceInstaller.StartType = ServiceStartMode.Automatic;
serviceInstaller.ServiceName = "Simple Service";
Installers.Add(serviceInstaller);
Installers.Add(processInstaller);
}
}
}
I'll be waiting for your feedback.
Best Regards.
|
|
|
|
|
You should still be able to debug it, but that's a topic for Visual Studio.
Do you get the log entry "System Logoff or System Shutdown"? If so, write some log entries in your email code to see if some function is failing.
Mark Salsbery
|
|
|
|
|
Dear Mark,
Testing my service with attached debugger and with a breakpoint at my SystemEvent Handler (private void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)), when i try to logoff or shutdown my pc, that breakpoint is never reached, because the debugger is first disabled.
Best Regards.
|
|
|
|
|
It could be that the machine does not have an SMTP account configure on it. Before your try to get your service to send an e-mail, try sending an e-mail from the it yourself. After you do that, yo must make sure that your windows service is able to use that SMTP e-mail account.
|
|
|
|
|
Dear Silim
Thank you for your fast response. That was the first test i've done. The smtp mail account is working fine. Only at SystemEvents Handler (private void SystemEvents_SessionEnding(object sender, SessionEndingEventArgs e)) isn't working.
Best regards.
|
|
|
|
|
|
Hi ganeshbdas,
Do you want to tell us something?
|
|
|
|
|
Hi friends in .net projects with calender and datepicker ctrl different different projects diff problems getting mostly browser issues. is there any permanent solution for that. even javascripts,or with ajaxctrl also getting problem.
this is challange for .net developers.
i am getting the prob in ie browser its working perfectly but in mozilla browser its not working.
modified 19-Nov-11 4:32am.
|
|
|
|
|
Since you haven't told us what the different problems are how are we supposed to answer?
No comment
|
|
|
|
|
We can answer through the medium of dance.
|
|
|
|
|
|
Ah, but do you come from a land down under? Where women glow and men plunder? Can't you hear, can't you hear the thunder? You'd better run, you'd better take cover.
|
|
|
|
|
You can dance if you want to. You CAN leave your friends behind.
|
|
|
|
|
suma.mca.4u wrote: this is challange for .net developers.
Do explain me why you consider this to be a challenge.
Bastard Programmer from Hell
|
|
|
|
|
|
As this is your first post, may I suggest that you read the various FAQ's under the Help[^] menu option.
|
|
|
|
|
Bye!
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
You forgot World.
No comment
|
|
|
|
|
Sup?
Yo yo yo yo. Dude. sssssssuupppppp
All the best,
Dan
|
|
|
|
|
Ignore the 1 votes. As you are new here, you probably aren't aware of the etiquette for posting here on Code Project. If you just want to post a general chew the fat type of post, then you should head to the lounge, soapbox, general indian or general chinese forums. Note that people tend to be a bit more tolerant of posters who are learning the ropes in the Indian forum. That might be a good place to start. Avoid the back room while you are new, it is not for the timid.
If you actually want to ask a technical question, pick the appropriate forum and ask it there. Try to be specific and make sure you have picked the most appropriate forum. For instance, don't pick the C# forum if your question is actually about Silverlight.
Anyway, welcome to Code Project.
|
|
|
|
|
I've actually 5éd it cause I found it "innocently" funny.
All the best,
Dan
|
|
|
|
|
I failed then. I was aiming for ironically funny.
|
|
|
|
|
Thanks for the greeting after more than 7 dormant years. What's up with you in the past 7 years?
|
|
|
|
|
You do realise this forum is to ask c# questions? Hence you have been flamed (rightly so). Try this in the lounge but expand a little bit: hello is great when you meet someone in person but a tad meaningless on it's own here.
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
Hello!
I'm, a novice student and have just started my first course in programming in VisualBasic C#.
We have been set with a task to program a word-game called LINGO (which already exist on this website)and ive been assigend to do the design-part of the programming. the game consist of a pictureBox with a grid on it (using drawLine) which creates 5 * 5 boxes.
I want to connect each "box" in the grid to a certain letter in a five-letter word, first letter in first box, second letter in second box etc. These words are to be put in through a textBox.
I have made an early draft with Coordinates for each word without any connection to the boxes or the pictureBox at all, they are simply put on top of the pictureBox.
this is the draft-code so far:
private void button1_Click(object sender, EventArgs e)
{
textBox_Input.Text.ToUpper();
Graphics grf = this.pictureBox_Output.CreateGraphics();
try
{
using (Font myFont = new Font("Arial", 40))
{
grf.DrawString(textBox_Input.Text, myFont, Brushes.Green, new PointF(4, 10));
grf.DrawString(textBox_Input.Text, myFont, Brushes.DarkRed, new PointF(4, 90));
grf.DrawString(textBox_Input.Text, myFont, Brushes.Yellow, new PointF(4, 170));
grf.DrawString(textBox_Input.Text, myFont, Brushes.DarkRed, new PointF(4, 250));
grf.DrawString(textBox_Input.Text, myFont, Brushes.Green, new PointF(4, 330));
}
}
finally
{
grf.Dispose();
}
Question:
How do i connect each "box" in the grid present on the pictureBox to a specific letter in a word? Is there an easier way to accomplish this?
NOTE: I've checked out the code of the existing LINGO-game on this website but couldnt make any out of it. (Like I said, novice ).
I'm very thankful for your help.
|
|
|
|