473,406 Members | 2,281 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

C# Service seems to fail on install but is working?

Hey All,

So I have a weird one for ya'll. Currently I have C# service that once started creates a thread which will read a stop tomcat if its started. Reads it to see if its been configured, if it hasn't it will write the file and then start it if not it will simply restart the tomcat service.

When I install my service(using NSIS and a DLL called simple service) I have some issues these two events show up in the event log simultaneously. First this one shows in the system log:

The (Service Name) service terminated unexpectedly. It has done this 1 time(s). The following corrective action will be taken in 60000 milliseconds: Restart the service.

Event ID:7031


and then this event in the Application log:

EventType clr20r3, P1 (Service name).exe, P2 1.0.0.0, P3 4c8ea600, P4 system.serviceprocess, P5 2.0.0.0, P6 4333aef4, P7 3a, P8 4e, P9 system.invalidoperationexception, P10 NIL.

Event ID:5000

After a few minutes or rebooting the system and logging in it will give me an message box with the information for the second error.

However after the install before rebooting. The Service is not only starting but it has rewritten the Tomcat Config File exactly the way I want it to. The error will never be seen again without uninstalling everything and reinstalling it.

Anyone have any idea on whats going on?

Thanks,
J
Sep 23 '10 #1
1 1954
This means there was an unhandled exception in your application that caused it to crash. From the error we can see where the exception occured.

EventType clr20r3,
P1 (Service name).exe,
P2 1.0.0.0, --app version
P3 4c8ea600, --app time stamp
P4 system.serviceprocess, -- module
P5 2.0.0.0, -- Assmple version
P6 4333aef4, -- Assembly timestamp
P7 3a, -- method def. metadata token.
P8 4e, -- Il offset
P9 system.invalidoperationexception, -- exception name
P10 NIL -- Nothing




Looks like you are using .Net 2.0 sp3. I wrote a quick snippet of code that will find the method given the metadata token.
Expand|Select|Wrap|Line Numbers
  1.             int token = 0x3a;
  2.             Type[] types = typeof(System.ServiceProcess.ServiceAccount).Assembly.GetTypes();
  3.             foreach (Type t in types)
  4.             {
  5.                 MethodInfo[] methods = t.GetMethods(BindingFlags.DeclaredOnly|BindingFlags.Public|BindingFlags.Static|BindingFlags.NonPublic|BindingFlags.Instance);
  6.                 foreach (MethodInfo m in methods)
  7.                 {
  8.                     if ((m.MetadataToken & 0xFFFFFF) == token)
  9.                     {
  10.                         Console.WriteLine(m.DeclaringType.Name + "." + m.Name);
  11.                         break;
  12.                     }
  13.                 }
  14.             }
  15.  

The methoddef is for ServiceBase.RequestAdditionalTime. For the IL offset 0x4e I see the InvalidOperationException being thrown.


Expand|Select|Wrap|Line Numbers
  1.     L_003f: ldstr "NotInPendingState"
  2.     L_0044: call string System.ServiceProcess.Res::GetString(string)
  3.     L_0049: newobj instance void [mscorlib]System.InvalidOperationException::.ctor(string)
  4.     L_004e: throw 
  5.  
  6.  
The C# code from reflection looks like this

Expand|Select|Wrap|Line Numbers
  1. [ComVisible(false)]
  2. public unsafe void RequestAdditionalTime(int milliseconds)
  3. {
  4.     fixed (NativeMethods.SERVICE_STATUS* service_statusRef = &this.status)
  5.     {
  6.         if (((this.status.currentState != 5) && (this.status.currentState != 2)) && ((this.status.currentState != 3) && (this.status.currentState != 6)))
  7.         {
  8.             throw new InvalidOperationException(Res.GetString("NotInPendingState"));
  9.         }
  10.         this.status.waitHint = milliseconds;
  11.         this.status.checkPoint++;
  12.         NativeMethods.SetServiceStatus(this.statusHandle, service_statusRef);
  13.     }
  14. }

Not reall sure what is calling this. Is this exception from your code or the installer? If it is from the installer can you tried installing the service instead with installutil.exe that comes .net. If the exception is coming from your code try adding some error logging so we can see a stack trace or something.
Sep 24 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ross Bennett | last post by:
Ahoy, Folks! I've been looking all over for this, but I just can't seem to shake any documentation out of the MSDN or from Google. I've reviewed every .NET article on developing Windows...
7
by: Axel Dahmen | last post by:
I've just installed Windows 2000 Service Pack 4 (SP4) on my Windows 2000 Server. Now I can't debug anymore! I'm using Visual Studio 7.0 (2002), ..NET Framework 1.0. The error message I get is...
2
by: cchisholm | last post by:
I have a web page in which I am displaying a .pdf file by way of response.redirect. The pdf file is on my machine along with IIS that is running the web page. As soon as I upgraded XP pro to...
2
by: | last post by:
i run the following: installutil "my service.exe" and it goes through and tells me the install and commit were successful. i go to the services list and it isn't shown. i've done this...
6
by: acool | last post by:
I managed to get my VB.NET service installed. Now I can't get it to do anything. Tell me how do you debug smething like this if you have to manually install the assembly to run it? the same code...
0
by: Jonas Bergman | last post by:
Hi I have a problem with an external web service that I use. Between 1 and 10 times out of 10 I get http error 400 Bad request if I call the web service from within VS 2003 (regardless if I...
5
by: yoinks | last post by:
Have vs.net 2005 loaded and am trying to install service pack 1 for 2.0 and get the following error. What do I have to un-install to install the service pack. Another verison of this product...
1
by: ncoathup.news | last post by:
Hi I am continually reminded that I have the .net 1.1 Service Pack 1 downloaded and available to install by Windows Update. However, it continually fails to install when selected. I already...
5
by: S Moran | last post by:
so i can use installutil to install the service on the machine the service was written on, but how can i take the EXE and install on another computer that doesnt have installutil? am i limited...
1
by: David | last post by:
Hi: How can I convert an application written in VS2005 to a service and then install it into Windows such that it will run when the computer is booted (before a user logs on) ? Dave
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.