473,394 Members | 2,002 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,394 software developers and data experts.

.NET Windows Service produces Exception errors?

I have created a Windows service which performs various functions
including setting variables in other application objects.

When the service runs under Local System account the functionality all
works OK, however when service runs under a user account it produces
exception errors when trying to set variables in the application
objects.

I created a .exe test harness which does the same and works OK when
run by the same user.

Anybody have any ideas on:
What is the difference when compiled as service compared to
application?
Why this works with service running under LocalSystem account and not
user account?
How can I get this to work with a user account?
Regards
Richard Marder
Nov 21 '05 #1
3 3884
Richard,
Without knowing specifically what "other application objects" you are using
and what exceptions you are receiving, its hard to say how to get it to
work.

Can you provided a complete yet short example of what you are attempting (10
to 20 lines of actual code) along with the exception you are receiving?

Hope this helps
Jay

"Richard" <ma*****@logica.com> wrote in message
news:4d**************************@posting.google.c om...
I have created a Windows service which performs various functions
including setting variables in other application objects.

When the service runs under Local System account the functionality all
works OK, however when service runs under a user account it produces
exception errors when trying to set variables in the application
objects.

I created a .exe test harness which does the same and works OK when
run by the same user.

Anybody have any ideas on:
What is the difference when compiled as service compared to
application?
Why this works with service running under LocalSystem account and not
user account?
How can I get this to work with a user account?
Regards
Richard Marder

Nov 21 '05 #2
Jay,

I am replying on behalf of Richard.

On our a Windows 2000 Production database server, a .NET Windows Service
called the PDCProcessor is unable to communicate with MapObjects COM
code to spatially register a point.

The box has the .NET Framework 1.0 and SDK installed and uses MapObjects
2.3.

Any ideas would be great!

1. This exception is thrown when we attempt to connect to the spatial
database to spatially register a point.

Event Type: Error
Event Source: PDCProcessor
Event Category: None
Event ID: 1
Date: 09/11/2004
Time: 16:08:06
User: N/A
Computer: RIMVDBS02
Description:
The description for Event ID ( 1 ) in Source ( PDCProcessor ) cannot be
found. The local computer may not have the necessary registry
information or message DLL files to display messages from a remote
computer. The following information is part of the event: 2004-11-09
16:08:06,817 [5308] FATAL Logica.RIMNET3.DAL.clsSpatialConnection -
SystemException Exception Type = System.InvalidCastException
Exception Message = QueryInterface for interface
ESRI.MapObjects2.Core.IMoDataConnection failed.
Exception Stack = at System.RuntimeType.InvokeDispMethod(String name,
BindingFlags invokeAttr, Object target, Object[] args, Boolean[]
byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.RuntimeType.ForwardCallToInvokeMember(Strin g memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData)
at ESRI.MapObjects2.Core.DataConnectionClass.set_Serv er(String A_1)
at Logica.RIMNET3.DAL.clsSpatialConnection.connectSDE (Boolean
boolRefDB)
..
2. This exception is thrown when we attempt to convert a grid reference
to an easting-northing.

Event Type: Error
Event Source: PDCProcessor
Event Category: None
Event ID: 0
Date: 09/11/2004
Time: 16:09:41
User: N/A
Computer: RIMVDBS02
Description:
The description for Event ID ( 0 ) in Source ( PDCProcessor ) cannot be
found. The local computer may not have the necessary registry
information or message DLL files to display messages from a remote
computer. The following information is part of the event: 2004-11-09
16:09:41,055 [3940] ERROR Logica.RIMNET3.GAD.clsPointConversion -
Exception: System.InvalidCastException
Message: QueryInterface for interface ESRI.MapObjects2.Core.IMoPoint
failed.
Source: mscorlib
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.RuntimeType.ForwardCallToInvokeMember(Strin g memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData)
at ESRI.MapObjects2.Core.PointClass.set_X(Double A_1)
at
Logica.RIMNET3.GAD.clsPointConversion.gridRefToEas tingNorthing(String
strGridRef, enmProjectionTypes& i32Projection)

..

3. The code that generates the second exception is:

Imports ESRI.MapObjects2.Core
Imports Logica.RIMNET3.DataAccess.Framework
Imports Logica.RIMNET3.DataAccess.SqlServer
Imports Logica.RIMNET3.common

Public Function gridRefToEastingNorthing(ByVal strGridRef As String,
ByRef i32Projection As enmProjectionTypes) As Point
'-----------------------------------------------------------------------
---
' Declarations

'-----------------------------------------------------------------------
---
Dim objPoint As Point
'-----------------------------------------------------------------------
---
' Database Declarations

'-----------------------------------------------------------------------
---
Dim objRequest As New DARequest()
Dim objFactory As DAFactory
Dim i32Easting As Int32
Dim i32Northing As Int32

Try

'-----------------------------------------------------------------------
---
' Setup the stored procedure

'-----------------------------------------------------------------------
---
objFactory = New SqlDataAccessHelper(m_i32OperatingMode)
objRequest.Command =
m_strSP_CONVERT_GRID_REF_TO_EAST_NORTH
'-----------------------------------------------------------------------
---
' Setup the parameters

'-----------------------------------------------------------------------
---
objRequest.PopulateParams(m_strARG_GRID_REF, strGridRef,
False)
objRequest.PopulateParams(m_strARG_REGION_CODE, "",
True)
objRequest.PopulateParams(m_strARG_EASTING, i32Easting,
True)
objRequest.PopulateParams(m_strARG_NORTHING,
i32Northing, True)
'-----------------------------------------------------------------------
---
' Get the converted NGR value

'-----------------------------------------------------------------------
---
objFactory.ExecuteNonQuery(objRequest)

If Not objRequest.GetParamValue(m_strARG_REGION_CODE) Is
System.DBNull.Value _
AndAlso Not
objRequest.GetParamValue(m_strARG_EASTING) Is System.DBNull.Value _
AndAlso Not
objRequest.GetParamValue(m_strARG_NORTHING) Is System.DBNull.Value Then

Select Case
CStr(objRequest.GetParamValue(m_strARG_REGION_CODE ))
Case m_strGRID_CODE_GB
i32Projection =
enmProjectionTypes.BritishNationalGrid
Case m_strGRID_CODE_IE
i32Projection =
enmProjectionTypes.IrishNationalGrid
Case m_strGRID_CODE_CI
i32Projection =
enmProjectionTypes.ChannelIslands
End Select

objPoint = New Point()
objPoint.X =
CDbl(objRequest.GetParamValue(m_strARG_EASTING))
objPoint.Y =
CDbl(objRequest.GetParamValue(m_strARG_NORTHING))

End If

Catch objDAExcp As DAException
If m_objLog.IsErrorEnabled Then
m_objLog.Error(objDAExcp)

Catch objExcp As Exception
If m_objLog.IsErrorEnabled Then m_objLog.Error(objExcp)

End Try
'-----------------------------------------------------------------------
---
' Return from the function

'-----------------------------------------------------------------------
---
If IsNothing(i32Projection) Or IsNothing(objPoint) Then
Throw New EastNorthNotObtainedException()
Else
Return objPoint
End If

End Function

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 21 '05 #3
Simon,
Sorry for the delay, holidays & what ever...

Are you certain that the MapObjects on your server is the same level as on
your development box?

The System.InvalidCastException would suggest that you may be looking for a
newer COM object (newer GUID) or a COM object that simply is not supported
in the version on your server.
Can you run the service, as a service, on the development box. Does it work?
It may be an authority thing with how services run.

Hope this helps
Jay


"Simon Berman" <si**********@logicacmg.com> wrote in message
news:OV**************@TK2MSFTNGP10.phx.gbl...
Jay,

I am replying on behalf of Richard.

On our a Windows 2000 Production database server, a .NET Windows Service
called the PDCProcessor is unable to communicate with MapObjects COM
code to spatially register a point.

The box has the .NET Framework 1.0 and SDK installed and uses MapObjects
2.3.

Any ideas would be great!

1. This exception is thrown when we attempt to connect to the spatial
database to spatially register a point.

Event Type: Error
Event Source: PDCProcessor
Event Category: None
Event ID: 1
Date: 09/11/2004
Time: 16:08:06
User: N/A
Computer: RIMVDBS02
Description:
The description for Event ID ( 1 ) in Source ( PDCProcessor ) cannot be
found. The local computer may not have the necessary registry
information or message DLL files to display messages from a remote
computer. The following information is part of the event: 2004-11-09
16:08:06,817 [5308] FATAL Logica.RIMNET3.DAL.clsSpatialConnection -
SystemException Exception Type = System.InvalidCastException
Exception Message = QueryInterface for interface
ESRI.MapObjects2.Core.IMoDataConnection failed.
Exception Stack = at System.RuntimeType.InvokeDispMethod(String name,
BindingFlags invokeAttr, Object target, Object[] args, Boolean[]
byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.RuntimeType.ForwardCallToInvokeMember(Strin g memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData)
at ESRI.MapObjects2.Core.DataConnectionClass.set_Serv er(String A_1)
at Logica.RIMNET3.DAL.clsSpatialConnection.connectSDE (Boolean
boolRefDB)
.
2. This exception is thrown when we attempt to convert a grid reference
to an easting-northing.

Event Type: Error
Event Source: PDCProcessor
Event Category: None
Event ID: 0
Date: 09/11/2004
Time: 16:09:41
User: N/A
Computer: RIMVDBS02
Description:
The description for Event ID ( 0 ) in Source ( PDCProcessor ) cannot be
found. The local computer may not have the necessary registry
information or message DLL files to display messages from a remote
computer. The following information is part of the event: 2004-11-09
16:09:41,055 [3940] ERROR Logica.RIMNET3.GAD.clsPointConversion -
Exception: System.InvalidCastException
Message: QueryInterface for interface ESRI.MapObjects2.Core.IMoPoint
failed.
Source: mscorlib
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers,
Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParameters)
at System.RuntimeType.ForwardCallToInvokeMember(Strin g memberName,
BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData&
msgData)
at ESRI.MapObjects2.Core.PointClass.set_X(Double A_1)
at
Logica.RIMNET3.GAD.clsPointConversion.gridRefToEas tingNorthing(String
strGridRef, enmProjectionTypes& i32Projection)

.

3. The code that generates the second exception is:

Imports ESRI.MapObjects2.Core
Imports Logica.RIMNET3.DataAccess.Framework
Imports Logica.RIMNET3.DataAccess.SqlServer
Imports Logica.RIMNET3.common

Public Function gridRefToEastingNorthing(ByVal strGridRef As String,
ByRef i32Projection As enmProjectionTypes) As Point
'-----------------------------------------------------------------------
---
' Declarations

'-----------------------------------------------------------------------
---
Dim objPoint As Point
'-----------------------------------------------------------------------
---
' Database Declarations

'-----------------------------------------------------------------------
---
Dim objRequest As New DARequest()
Dim objFactory As DAFactory
Dim i32Easting As Int32
Dim i32Northing As Int32

Try

'-----------------------------------------------------------------------
---
' Setup the stored procedure

'-----------------------------------------------------------------------
---
objFactory = New SqlDataAccessHelper(m_i32OperatingMode)
objRequest.Command =
m_strSP_CONVERT_GRID_REF_TO_EAST_NORTH
'-----------------------------------------------------------------------
---
' Setup the parameters

'-----------------------------------------------------------------------
---
objRequest.PopulateParams(m_strARG_GRID_REF, strGridRef,
False)
objRequest.PopulateParams(m_strARG_REGION_CODE, "",
True)
objRequest.PopulateParams(m_strARG_EASTING, i32Easting,
True)
objRequest.PopulateParams(m_strARG_NORTHING,
i32Northing, True)
'-----------------------------------------------------------------------
---
' Get the converted NGR value

'-----------------------------------------------------------------------
---
objFactory.ExecuteNonQuery(objRequest)

If Not objRequest.GetParamValue(m_strARG_REGION_CODE) Is
System.DBNull.Value _
AndAlso Not
objRequest.GetParamValue(m_strARG_EASTING) Is System.DBNull.Value _
AndAlso Not
objRequest.GetParamValue(m_strARG_NORTHING) Is System.DBNull.Value Then

Select Case
CStr(objRequest.GetParamValue(m_strARG_REGION_CODE ))
Case m_strGRID_CODE_GB
i32Projection =
enmProjectionTypes.BritishNationalGrid
Case m_strGRID_CODE_IE
i32Projection =
enmProjectionTypes.IrishNationalGrid
Case m_strGRID_CODE_CI
i32Projection =
enmProjectionTypes.ChannelIslands
End Select

objPoint = New Point()
objPoint.X =
CDbl(objRequest.GetParamValue(m_strARG_EASTING))
objPoint.Y =
CDbl(objRequest.GetParamValue(m_strARG_NORTHING))

End If

Catch objDAExcp As DAException
If m_objLog.IsErrorEnabled Then
m_objLog.Error(objDAExcp)

Catch objExcp As Exception
If m_objLog.IsErrorEnabled Then m_objLog.Error(objExcp)

End Try
'-----------------------------------------------------------------------
---
' Return from the function

'-----------------------------------------------------------------------
---
If IsNothing(i32Projection) Or IsNothing(objPoint) Then
Throw New EastNorthNotObtainedException()
Else
Return objPoint
End If

End Function

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: MatthewRoberts | last post by:
Howdy All, I have a Windows Service that often stops in its tracks with no exception and no explanation on our QA system. During testing on the development machine, it can handle any workload,...
12
by: JSheble | last post by:
I've written a Windows Service using C#, but I cannot seem to figure out how to cancel or prevent the service from starting under certain conditions. For example, in the OnStart I read in some...
6
by: Nathan Kovac | last post by:
Yesterday afternoon I was getting the following errors in a windows service: 'DatabaseManager.DataComponent', 'Error', '3 Errors: Line: 0 - Metadata file 'ScriptingMethods.dll' could not be found...
3
by: Gerard | last post by:
Hello I have created a windows service to monitor a database, it starts some checks when a timer elapses. The checks send emails depending on their findings. My issue is that when I created a...
7
by: Larry Bird | last post by:
I have a windows service that want to un-install. When I run "installutil /u serivcename" I get the error that the serivce is not installed on my machine. However, when view the serivce console I...
4
by: Groundskeeper | last post by:
I can't seem to get a custom UnhandledException handler working for a Windows Service I'm writing in VB.NET. I've read the MSDN and tried various different placements of the AddHandler call, to no...
0
by: PhilHip | last post by:
I've written a Windows service in VB.Net that accesses the global address list to obtain all the entries to store them in a local database. The GAL is accessed using the MS Exchange profile on the...
2
by: Trevor | last post by:
Argh! This problem is driving me nuts! Can you help? In November of 2003, I installed a web service on Windows Server 2003 built in VB.NET for v1.1.4322 of the framework. It contains a timer...
7
by: shai | last post by:
I am working at .net 1.1, writing in c#. I have windows service with a COM object. Every unexpected time The COM object throw an error that make my service get stuck (do not respond). I can catch...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.