|
I was doing a C# windows service. the service installs and runs well on my machine, but when i deploy on server (Windows server 2003), and try to start it, i get the dreaded 'Error 1067: application terminated unexpectedly'!
What to do?
some of the code is shown below:
i was doing a C# windows service. the service installs and runs well on my machine, but when i deploy on server (Windows server 2003), and try to start it, i get the dreaded 'Error 1067: application terminated unexpectedly'!
What to do?
some of the code is shown below:
[RunInstaller(true)]
public partial class MessagingInstaller : Installer
{
public MessagingInstaller()
{
InitializeComponent();
}
}
public partial class MessagingService : ServiceBase
{
private MessagingLogic msglgc;
public MessagingService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
if (!EventLog.SourceExists("MessageLogger"))
EventLog.CreateEventSource("MessageLogger", "Event Logger");
var _log = new EventLog { Source = "MessageLogger" };
try
{
if (msglgc == null)
msglgc = new MessagingLogic();
msglgc.Start();
}
catch (ArgumentException exception)
{ _log.WriteEntry("OnStart Error: " + exception.Message); }
}
protected override void OnStop()
{
if (!EventLog.SourceExists("MessageLogger"))
EventLog.CreateEventSource("MessageLogger", "Event Logger");
var _log = new EventLog { Source = "MessageLogger" };
try
{
if (msglgc != null)
msglgc.Stop();
}
catch (ThreadAbortException exception)
{ _log.WriteEntry("OnStop Error: " + exception.Message); }
}
}
Please help! I need the solution as soon as possible
modified 14-Dec-11 11:00am.
|
|
|
|
|
Does msglgc get initialized to null ? Does it keep running? And shouldn't the Stop method set it back to null ?
|
|
|
|
|
Does the new log get created, do you see any messages, normal or exception ...? Try and gather some more information about exactly where it is failing.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
eyesark wrote: Please help!
You are assuming that only one possible exception can occur in OnStart.
However if any exception occurs in there then windows will think that the service didn't start.
You can look at System.ServiceProcess.ServiceBase.AutoLog.
If set to true, before any real processing then if OnStart exits with an exception then an event log entry will be written with the exception stack trace.
|
|
|
|
|
I suspect that the problem is to do with registering the event source. If you don't have enough privileges to do this, the application will abort at the point you are trying to do this because you are creating it outside of the try/catch block.
|
|
|
|
|
Hi all,
I have created one windows setup application,when i installed it on the system if i click two times the application is running two times as it should run once.
How can i solve it ?
Thanks in advance.
|
|
|
|
|
You should run your app using the Mutex class, something like this:-
bool isNew = true;
using (Mutex mutex = new Mutex(true, "yourAppName", out isNew))
{
if (isNew)
{
Application.Run(new MainForm());
}
}
If the app is aplready running and you would like it to be given focus you need to use a Win32 API method called SetForegroundWindow which I'm sure you could find an instance of on Google.
Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
I didn't know about this. Very handy.
|
|
|
|
|
Thanks!
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
|
|
|
|
|
|
WARNING: all the schemes that have been mentioned to you do not prevent the app from launching a second or third time; all they do is try and make the app terminate pretty soon if it isn't the first instance.
|
|
|
|
|
Luc Pattyn wrote: all the schemes that have been mentioned to you do not prevent the app from launching a second or third time Even the one from Wayne G. using a Mutex ?
thanks, Bill
When I consider the brief span of my life, swallowed up in the eternity before and after, the little space which I fill, and even can see, engulfed in the infinite immensity of spaces of which I am ignorant, and which knows me not, I am frightened, and am astonished at being here rather than there; for there is no reason why here rather than there, now rather than then. Blaise Pascal
|
|
|
|
|
It still has to start to detect that there's another instance running. It's not that they don't stop the appearance of an app not being started again, but there will always be a finite period of time where the second instance has spun up - even if it then terminates.
|
|
|
|
|
CP has many articles on making a "Singleton" app:[^]
When I consider the brief span of my life, swallowed up in the eternity before and after, the little space which I fill, and even can see, engulfed in the infinite immensity of spaces of which I am ignorant, and which knows me not, I am frightened, and am astonished at being here rather than there; for there is no reason why here rather than there, now rather than then. Blaise Pascal
|
|
|
|
|
How to tell the OS to use the environment provided by the WinForm application instead from system environment.
Example : My WinForm application uses C++ runtime dll's(msvcm80.dll, msvcp80.dll and msvcr80.dll) and bundling them as part of the application. How to make sure that my application will use the C++ runtime dll's that bundled along with product even though the dll's present else where in the system(c:\Windows\Winsxs).
Regards,
Gopal Reddy
|
|
|
|
|
|
Posting this question in the C++ forum can help you get more answers.
|
|
|
|
|
Hi all,
I have created one windows application setup.Now i want to display mt application shortcut in the menu that is when i left click on the file it should display the application name in the menu.
How can i do it ?
Thanks in advance.
|
|
|
|
|
Are you asking how to create a file association, so that when you are on the Desktop, or in a Windows Explorer window, and you context-click on a file whose type is the type you have associated: then you want the Windows system context menu to appear with the name of your application under the "Open With" sub-menu ?
Have you set the left mouse button to be the context-click button ?
When I consider the brief span of my life, swallowed up in the eternity before and after, the little space which I fill, and even can see, engulfed in the infinite immensity of spaces of which I am ignorant, and which knows me not, I am frightened, and am astonished at being here rather than there; for there is no reason why here rather than there, now rather than then. Blaise Pascal
|
|
|
|
|
Hi,
I have a textbox, and i want to show the value of this textbox in another window form?
Any one can help me?
Thanks!
|
|
|
|
|
Is this other form open already? Do you want the value to be displayed when the user clicks a button, or is it to be updated as the user types? You need to provide more information before anyone can offer useful help.
|
|
|
|
|
Yes, this form is already open, I wants to link it with this. And i want to open the this by button click,
|
|
|
|
|
The common way to do this is to have an event in your code that looks something like this:
public event EventHandler<string> MyText;
protected void OnMyTextChanged()
{
EventHandler<string> handler = MyText;
if (handler == null)
{
return;
}
handler(this, new TextChangedEventArgs(textBox.Text));
} Then, all you need do is subscribe to the event in the second form, and it will automatically receive the string whenever you raise this event (which you would trigger from your button click event). Note that TextChangedEventArgs is a custom event args class defined like this:
public class TextChangedEventArgs : EventArgs
{
public TextChangedEventArgs(string text) : base()
{
MyText = text;
}
public string MyText { get; private set; }
}
|
|
|
|
|
Use the customeventhandler functionality of .net
Varun Sareen (Dot Net Developer)
|
|
|
|
|
hi
can someone help me about storage binding in string type?
I need a rich answer
thanks so much
|
|
|
|