Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1548
  • Last Modified:

Cannot run .net 2.0 windows service on production server

Hi .
I have a windows service in .NET 2.0 - it works fine on my dev machine .
When trying to start a windows service on production server
i get the "Process terminated unexpectedly" message  and the following exception :

EventType clr20r3, P1 myservice.exe, P2 1.0.0.0, P3 44717e13, P4 mscorlib, P5 2.0.0.0, P6 4333ab80, P7 51e4, P8 61, P9 n51cffzwz1gffvslvrub5uxq1gvd0txu, P10 NIL.

the server runs Windows Server 2003 SP1 Standart Edition
.NET framework is v2.0.50727 on both server and dev machine .

Thanks in advance
0
amishel
Asked:
amishel
  • 11
  • 11
1 Solution
 
jhanceCommented:
Clearly you have an exception and an unhandled one at that.  My suggestion is to be sure you've handled every possible exception that might happen in your code and log it to the event log or to a file.  Include the details.  Then, at least, you'd know where in your code this is coming from and might have a clue as to how to fix it.
0
 
amishelAuthor Commented:
I tried but it never writes an exception to log i don't even think that it reches the service OnStart event
I think the problem is somehow related to project references since it works fine on machines that have
Visual Studio 2005  installed
0
 
amishelAuthor Commented:
I have also tried to copy all of the referenced .NET assemblies to the service folder .
The service uses .NEt remoting - it opens a listener on IPC channel .
Could that be related to some caspol settings ?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jhanceCommented:
A lot needs to happen before the OnStart method is reached.  Put some logging code up to the very beginning of your code in the Main() function.  See if you can determine how far into your code it gets.  

Obviously ALL of the assemblies referenced in your application must be available on the target machine.
0
 
amishelAuthor Commented:
Did as you told me -
the exception is thrown in the Sub Main on line System.ServiceProcess.ServiceBase.Run(ServicesToRun)
0
 
jhanceCommented:
Ok, but WHAT is the specific exception?
0
 
jhanceCommented:
MSDN docs say that this only throws a Win32Exception (but I've found that MSDN is not always accurate in that respect).  A Win32Exception should get you to a WIN32 error code.
0
 
amishelAuthor Commented:
EventType clr20r3, P1 myservice.exe, P2 1.0.0.0, P3 44717e13, P4 mscorlib, P5 2.0.0.0, P6 4333ab80, P7 51e4, P8 61, P9 n51cffzwz1gffvslvrub5uxq1gvd0txu, P10 NIL.

 is the exact exceprion i get - nothing  less
0
 
jhanceCommented:
No, that's the event log message.  

You've put an exception handler in your code, right?  What is:

ex.ErrorCode
ex.Message
ex.NativeErrorCode
ex.Source
0
 
amishelAuthor Commented:
Source: .NET Runtime 2.0 Error Reporting
EventID : 5000
0
 
jhanceCommented:
What about what I asked for?
0
 
amishelAuthor Commented:
I cannot debug it remotely cuz it terminates in a second
0
 
jhanceCommented:
I didn't suggest that you debug it.  I suggested that you put in some code to capture and report what is going on.  You still have an exception being thrown, you now know WHERE is it but you don't this WHAT is causing it.

If nothing else, open a log file and write the exception data to the file.

0
 
amishelAuthor Commented:
That's exactly what i did but all the data that it has is what I 've mentioned above
0
 
amishelAuthor Commented:
I have also checked for all inner exceptions and stack trace but the only content it has is :

EventType clr20r3, P1 myservice.exe, P2 1.0.0.0, P3 44717e13, P4 mscorlib, P5 2.0.0.0, P6 4333ab80, P7 51e4, P8 61, P9 n51cffzwz1gffvslvrub5uxq1gvd0txu, P10 NIL.

I've googled for EventType clr20r3, P1 and there's couple of guys there who have same thing
but couldn't figure out the solution
0
 
jhanceCommented:
Please show your code surrounding:

System.ServiceProcess.ServiceBase.Run(ServicesToRun)
0
 
amishelAuthor Commented:
It's autogenerated code :

    Shared Sub Main()
        Try
            Dim ServicesToRun() As System.ServiceProcess.ServiceBase
            ServicesToRun = New System.ServiceProcess.ServiceBase() {New MyService}
            System.ServiceProcess.ServiceBase.Run(ServicesToRun)
        Catch ex As Exception
            My.Application.Log.WriteException(ex)
        End Try
    End Sub
0
 
jhanceCommented:
And what does WriteException() do?
0
 
jhanceCommented:
By the way, I'm really trying to help but it's hard when you will only dribble out small bits of information...
0
 
amishelAuthor Commented:
Well - i don't know why but after i've installed .NET 2.0 SDK on the server (i wanted to use caspol and gacutil tools)
the service works ....
                               Thanks anyway , jhance
0
 
jhanceCommented:
Ok...
0
 
amishelAuthor Commented:

My.Application.Log.WriteException is the method in My namespace that writes and excetion to a default listener
0
 
GranModCommented:
PAQed with points refunded (125)

GranMod
Community Support Moderator
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

  • 11
  • 11
Tackle projects and never again get stuck behind a technical roadblock.
Join Now