Windows Service Problem

B

badar.waqas

I have written Windows Service in C#. It runs fine on my PC. I have
tested it on other systems on office. It runs fine on all PC. But when
i moved it to production system it is not running. I am able to
install it on production system. But when i try to run it, following
error is given to me:

"Error 1053: The service did not respond to start or control request
in timely fashion"

And when i try to uninstall it. It gives me following error

Exception occur while initializing the installation:
System. BadImageFormatException: could not load file or assembly or
one of its dependency. The module was excepted to contain a assembly
manifest.


I write again another simple window service which does nothing. But it
also gives above error.
 
M

Mr. Arnold

I have written Windows Service in C#. It runs fine on my PC. I have
tested it on other systems on office. It runs fine on all PC. But when
i moved it to production system it is not running. I am able to
install it on production system. But when i try to run it, following
error is given to me:

"Error 1053: The service did not respond to start or control request
in timely fashion"

And when i try to uninstall it. It gives me following error

Exception occur while initializing the installation:
System. BadImageFormatException: could not load file or assembly or
one of its dependency. The module was excepted to contain a assembly
manifest.


I write again another simple window service which does nothing. But it
also gives above error.

You need to use the Eventlog and write to the eventlog on the Onstart event
to trace where the application is going and where it is blowing up, use some
try/catches.

It's blowing up in the Onstart and is timing out.
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

What do you do in the onStart method?
Also log AppDomain.UnhandledException and Thread.ThreadException
 
A

Andrej Tozon

... and make sure you copy all dependant dll-s on the production
system, ensure it runs the same .NET framework version you're
targeting, ...

Andrej
 
P

Phil Wilson

Badimageformat is typically caused running a 1.1 assembly that then tries to
load a 2.0 assembly. With installer classes installing your service you can
get this error if you have installer classes that were built with the 1.1
framework that fail because they are running on a system without the 1.1
framework, so they would attempt to load 2.0 and fail. This isn't anything
to do with config files or whether your code can run with 2.0, it's because
there are explicit loads in installer class infrastructure that will try to
load assemblies, and if 1.1 tries to load 2.0 it will fail.
 
B

badar.waqas

You need to use the Eventlog and write to the eventlog on the Onstart event
to trace where the application is going and where it is blowing up, use some
try/catches.

It's blowing up in the Onstart and is timing out.

Yes it try to log it. But nothing goes in log entries.
 
B

badar.waqas

Hi,

What do you do in the onStart method?
Also log AppDomain.UnhandledException and Thread.ThreadException

Nothing. Below is the code of my service1 class:

public partial class Service1 : ServiceBase
{
public Service1()
{
try
{
InitializeComponent();
this.ServiceName = "testService";
this.EventLog.Log = "Application";

// These Flags set whether or not to handle that
specific
// type of event. Set to true if you need it, false
otherwise.
this.CanHandlePowerEvent = true;
this.CanHandleSessionChangeEvent = true;
this.CanPauseAndContinue = true;
this.CanShutdown = true;
this.CanStop = true;
}
catch (Exception ex)
{
EventLog.WriteEntry("test service", ex.Message,
EventLogEntryType.Error);
}
}

protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
try
{
}
catch (Exception ex)
{
EventLog.WriteEntry("test service", ex.Message,
EventLogEntryType.Error);
}

}

protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary
to stop your service.
}
}
And that is the code of installer:

[RunInstaller(true)]
public partial class Installer1 : Installer
{
public Installer1()
{
InitializeComponent();

ServiceProcessInstaller serviceProcessInstaller = new
ServiceProcessInstaller();
ServiceInstaller serviceInstaller = new
ServiceInstaller();

//# Service Account Information
serviceProcessInstaller.Account =
ServiceAccount.LocalSystem;
serviceProcessInstaller.Username = null;
serviceProcessInstaller.Password = null;

//# Service Information
serviceInstaller.DisplayName = "test service";
serviceInstaller.Description = "Service collect
information like current map, mod, players info etc.";
serviceInstaller.StartType = ServiceStartMode.Automatic;

// This must be identical to the
WindowsService.ServiceBase name
// set in the constructor of WindowsService.cs
serviceInstaller.ServiceName = "testService";

this.Installers.Add(serviceProcessInstaller);
this.Installers.Add(serviceInstaller);
}
}
IF ANY THING WRONG IN INSTALLATION CODE THEN PLEASE LET ME
KNOW?????????????????????????
 
B

badar.waqas

... and make sure you copy all dependant dll-s on the production
system, ensure it runs the same .NET framework version you're
targeting, ...

Andrej

I have made another very simple application. I think there is no
dependency other than .NET 2.0
 
B

badar.waqas

Badimageformat is typically caused running a 1.1 assembly that then tries to
load a 2.0 assembly. With installer classes installing your service you can
get this error if you have installer classes that were built with the 1.1
framework that fail because they are running on a system without the 1.1
framework, so they would attempt to load 2.0 and fail. This isn't anything
to do with config files or whether your code can run with 2.0, it's because
there are explicit loads in installer class infrastructure that will try to
load assemblies, and if 1.1 tries to load 2.0 it will fail.
--
Phil Wilson
[MVP Windows Installer]


I have written Windows Service in C#. It runs fine on my PC. I have
tested it on other systems on office. It runs fine on all PC. But when
i moved it to production system it is not running. I am able to
install it on production system. But when i try to run it, following
error is given to me:
"Error 1053: The service did not respond to start or control request
in timely fashion"
And when i try to uninstall it. It gives me following error
Exception occur while initializing the installation:
System. BadImageFormatException: could not load file or assembly or
one of its dependency. The module was excepted to contain a assembly
manifest.
I write again another simple window service which does nothing. But it
also gives above error.
I have done it as well. I compiled it on Visual Studio 2005 on .Net
2.0
 
M

Mr. Arnold

On Feb 11, 8:21 pm, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.com> wrote:

<snipped>

I see you have got that installer crap in the solution. I have never used
it. I have seen someone else post that was using that installer crap, which
give him trouble. I think that's where you're blowing up some kind of way is
because of that installer crap in the solution.
 
B

badar.waqas

<snipped>

I see you have got that installer crap in the solution. I have never used
it. I have seen someone else post that was using that installer crap, which
give him trouble. I think that's where you're blowing up some kind of way is
because of that installer crap in the solution.

I install .Net 2.0 from the same setup which i use on my local
machine. I think that is not issue. ANY OTHER CLUE TO RESOLVE THIS
PROBLEM?
 
M

Mr. Arnold

I install .Net 2.0 from the same setup which i use on my local
machine. I think that is not issue. ANY OTHER CLUE TO RESOLVE THIS
PROBLEM?

Get rid of the installer crap out of the solution and see what happens,
because you don't need it, if the only reason you're using it is to create
an Eventlog. You can create an Eventlog on the fly with .Net without using
an installer to do it. What do you have to loose by doing it. It's called
process of elimination.

What happened to InstallUtil, which can be used to install and uninstall a
Windows service application?

The second thing you can do is enable the Messenger Service on the machine,
and in code, trap the machine-name and use the machine-name with the NET
SEND command to send a message to the machine, which pops-up a message-box
to the monitor. You put the NET SEND commands in areas so that you see if
the service is making it to certain points in trying to pin point what
statement is aborting the application, since you CANNOT EVEN DUMP ANYTHING
TO THE EVENTLOG. This is the best that I can do for, as I don't have a
crystal ball nor am I sitting in a chair next to you. You're going to have
to dig it out with using your abilities to debug the solution.
 
P

Pankaj Karna

I have written Windows Service in bandwidthd software . It runs fine on
my PC. I have
tested it on other systems on office. It runs fine on all PC. But when
i moved it to production system it is not running. I am able to
install it on production system. But when i try to run it, following
error is given to me:

"Error 1053: The service did not respond to start or control request
in timely fashion"

And when i try to uninstall it. It gives me following error

Exception occur while initializing the installation:
System. BadImageFormatException: could not load file or assembly or
one of its dependency. The module was excepted to contain a assembly
manifest.


I write again another simple window service which does nothing. But it
also gives above error.
 
B

badar.waqas

Get rid of the installer crap out of the solution and see what happens,
because you don't need it, if the only reason you're using it is to create
an Eventlog. You can create an Eventlog on the fly with .Net without using
an installer to do it. What do you have to loose by doing it. It's called
process of elimination.

What happened to InstallUtil, which can be used to install and uninstall a
Windows service application?

The second thing you can do is enable the Messenger Service on the machine,
and in code, trap the machine-name and use the machine-name with the NET
SEND command to send a message to the machine, which pops-up a message-box
to the monitor. You put the NET SEND commands in areas so that you see if
the service is making it to certain points in trying to pin point what
statement is aborting the application, since you CANNOT EVEN DUMP ANYTHING
TO THE EVENTLOG. This is the best that I can do for, as I don't have a
crystal ball nor am I sitting in a chair next to you. You're going to have
to dig it out with using your abilities to debug the solution.

Thanks Mr. Arnold to guide me. I agree with u that i have to solve it
by using my abilities. Currently production servers are down when they
will up i will check it by coding as u guide me. Again thanks for ur
effort which u have put for me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top