Adding web services created in VS2003 to VS 2005 smart device projects as web references

I've been trying to add a web reference to a web service that was created some time ago in Visual Studio 2003. This web service works fine and is linked to from several smart device projects.
When I add a web reference to the web service in a Visual Studio 2005 Beta 2 smart device project (compact framework 2.0) it seems to work fine until I go to build the solution. The build constantly fails with the following message in the output window.
"Error: Could not load file or assembly 'System.Data.SqlServerCe, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
- Could not load file or assembly 'file:///c:\program files\microsoft visual studio 8\smartdevices\sdk\sql server\mobile\v3.0\system.data.sqlserverce.dll' or one of its dependencies. The system cannot find the file specified."
When I go into windows explorer to look at the sqlserverce.dll file it exists although the version number I see is different to the one given in the error message.
If I delete the web reference from the project that contains it the solution will build fine. Has anyone else had this problem and if you did how did you fix it. I don't really want to reimplement the web service under Visual Studio 2005 at this point in time.

[1340 byte] By [Hayley] at [2008-2-18]
# 1
I've now implemented another webservice in 2005 to see if it is a web reference issue in general or just the 2003 webservice. I still get the same error regardless of the framework the webservice was created in. Help anyone?
Hayley at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...
# 2
Hayley,

Does your webservice use SqlMobile at all? Does it actually reference the assembly you are having trouble with? If you could post your sample project that illustrates the problem that would be very helpful.

Neil

NeilEnnsMSFT at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...
# 3
Hayley,

Same exact problem here. (VS 2005 beta2/SQLMobile)

Only difference is that my app builds and runs just fine under 'Debug'. If I switch to 'Release', I get the same thing you reported down to the letter. I don't have a solution to offer yet. I am still trying to work it out.

Will post back if i find something.

ScoobyBlue at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...
# 4
Hi Neil,
My webservice does not use SqlMobile at all. It is a framework 1.0 application written in VB using VS 2003. I've included the code for the one web service method that the application uses and the code that the smart device uses to access the web service. The rest of the code in the smart device application deals with creating and downloading database information.
Hayley

Web Service Code
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
<WebService(Namespace:="http://www.tempuri.org/OnlineStatus/SyncServStatus/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
Public Class SyncServStatus
Inherits System.Web.Services.WebService
Public Sub SyncServStatus()
End Sub
<WebMethod()> _
Public Function GetServerStatus() As ServerStatus
' For the moment we can only get this information from a flat
' file on the server. Ultimately we will want to set up a basic
' database to deal with this (even a small footprint mysql would
' be fine.
Dim strPath As String
Try
Dim configReader As New System.Configuration.AppSettingsReader
strPath = CType(configReader.GetValue("StatusPath", GetType(String)), String)
Catch exInvalid As InvalidOperationException
' DerivedSyncServProcessor needs to be setup in web.config file.
Throw New Exception("StatusPath not found in web.config", exInvalid)
Catch exNull As ArgumentNullException
Throw New Exception("Value of StatusPath in web.config is nothing", exNull)
End Try
Dim objStatus As New ServerStatus
Dim ds As New StatusDataSet
'Dim row As Data.DataRow = ds.ServerStatus.NewRow()
'row.Item("IsOnline") = True
'row.Item("IsDowntimeScheduled") = False
'row.Item("CurrentServerTime") = Date.Now
'row.Item("NextDowntime") = Date.Now
'row.Item("Message") = ""
'row.Item("ExpectedDowntimeLengthMinutes") = 0
'ds.ServerStatus.Rows.Add(row)
'ds.WriteXml(strPath)
ds.ReadXml(strPath)
If ds.ServerStatus.Rows.Count = 1 Then
objStatus.IsOnline = CType(ds.ServerStatus.Rows(0), StatusDataSet.ServerStatusRow).IsOnline
objStatus.IsDowntimeScheduled = CType(ds.ServerStatus.Rows(0), StatusDataSet.ServerStatusRow).IsDowntimeScheduled
objStatus.CurrentServerTime = DateTime.Now
objStatus.NextDowntime = CType(ds.ServerStatus.Rows(0), StatusDataSet.ServerStatusRow).NextDowntime
objStatus.Message = CType(ds.ServerStatus.Rows(0), StatusDataSet.ServerStatusRow).Message
objStatus.ExpectedDowntimeLengthMinutes = CType(ds.ServerStatus.Rows(0), StatusDataSet.ServerStatusRow).ExpectedDowntimeLengthMinutes
End If
Return objStatus
End Function
Public Class ServerStatus
' Flag to indicate if the server is currently available
Public IsOnline As Boolean
' Flag to indicate if downtime is scheduled for the future
Public IsDowntimeScheduled As Boolean
' Current server time
Public CurrentServerTime As DateTime
' Time of next scheduled downtime
Public NextDowntime As DateTime
Public ExpectedDowntimeLengthMinutes As Integer
' Message to display to the user
Public Message As String
End Class
End Class

Smart Device Code that handles the web service

Namespace OnlineStatus
Public Class OnlineStatusHH
Public Enum ConnectionStatus
Online
NotOnline
DownForService
DueForService
ConnectionFailure
NameResolutionFailure
ProtocolFailure
GeneralFailure
End Enum
Public Class StatusReturn
Public Message As String
Public OriginalException As Exception
Public ConnectionStatus As ConnectionStatus = ConnectionStatus.Online
Public MinutesTillBackOnline As Integer = -1
End Class
Private cvstrURL As String
Private Const DOWNTIME_LEAD_MINUTES As Integer = 30
Public Sub New(ByVal strURL As String)
cvstrURL = String.Format("{0}OnlineStatus/SyncServStatus.asmx", strURL)
End Sub
Public Function CheckOnlineStatus() As StatusReturn
Dim objRet As New StatusReturn
Try
' Lets check if we are online and what the
' status of the server is.
Dim objStatusChecker As New OnlineStatus.SyncServStatus 'OnlineStatus.SyncServStatus
objStatusChecker.Url = cvstrURL
Dim objStatus As OnlineStatus.ServerStatus = objStatusChecker.GetServerStatus
If objStatus.IsDowntimeScheduled Then
Dim objTimeSpanToDowntime As TimeSpan = objStatus.NextDowntime.Subtract(objStatus.CurrentServerTime)
If objTimeSpanToDowntime.TotalMinutes < 0 Then
' Downtime is scheduled for the past
If Not objStatus.IsOnline Then
If Len(objStatus.Message) > 0 Then
objRet.Message = objStatus.Message
Else
objRet.Message = String.Format("The server is currently down for service. It is due to become available in {0} minutes.", CStr(CInt(objTimeSpanToDowntime.TotalMinutes + objStatus.ExpectedDowntimeLengthMinutes)))
End If
objRet.ConnectionStatus = ConnectionStatus.DownForService
objRet.MinutesTillBackOnline = CInt(objTimeSpanToDowntime.TotalMinutes + objStatus.ExpectedDowntimeLengthMinutes)
Return objRet
End If
ElseIf objTimeSpanToDowntime.TotalMinutes < DOWNTIME_LEAD_MINUTES Then
' Downtime is scheduled for within the next 30 minutes
If Len(objStatus.Message) > 0 Then
objRet.Message = objStatus.Message
Else
objRet.Message = String.Format("The server is due to go down for service and you cannot sync at this time. It is due to become available in {0} minutes.", CStr(CInt(objTimeSpanToDowntime.TotalMinutes + objStatus.ExpectedDowntimeLengthMinutes)))
End If
objRet.ConnectionStatus = ConnectionStatus.DueForService
objRet.MinutesTillBackOnline = CInt(objTimeSpanToDowntime.TotalMinutes + objStatus.ExpectedDowntimeLengthMinutes)
Return objRet
End If
End If
If Not objStatus.IsOnline Then
If Len(objStatus.Message) > 0 Then
objRet.Message = objStatus.Message
Else
objRet.Message = "The server is not currently online. Please try again later."
End If
objRet.ConnectionStatus = ConnectionStatus.NotOnline
Return objRet
End If
Catch exWeb As System.Net.WebException
' This exception can be thrown in a number of situations, including
' when there is no connection to the internet, or when the remote
' host name cannot be resolved.
' Now tell the user about it.
objRet.OriginalException = exWeb
Select Case exWeb.Status
Case Net.WebExceptionStatus.ConnectFailure
objRet.ConnectionStatus = ConnectionStatus.ConnectionFailure
objRet.Message = String.Concat(exWeb.Message, " - Please ensure you are connected to the internet.")
Case Net.WebExceptionStatus.NameResolutionFailure
objRet.ConnectionStatus = ConnectionStatus.NameResolutionFailure
objRet.Message = "The remote server name could not be resolved. Please contact support."
Case Net.WebExceptionStatus.ProtocolError
objRet.ConnectionStatus = ConnectionStatus.ProtocolFailure
objRet.Message = String.Format("A networking protocal error occured. Please contact support. Response Details: {0}-{1}", _
CType(exWeb.Response, System.Net.HttpWebResponse).StatusCode, _
CType(exWeb.Response, System.Net.HttpWebResponse).StatusDescription)
Case Else
objRet.ConnectionStatus = ConnectionStatus.GeneralFailure
objRet.Message = exWeb.Message
End Select
Return objRet
End Try
Return objRet
End Function
End Class
End Namespace

Hayley at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...
# 5
Hayley and ScoobyBlue,

Did either of you happen to look at forum post http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=19571 ? If so, did you try the fixes that I detailed? If you haven't, please give them a try and let me know if they fix your problems.

Thanks,
Keith
Tester - VS for Devices

KeithJones at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...
# 6
Hi Kevin,
Thanks so much that got it all working fine.
Hayley at 2007-9-9 > top of Msdn Tech,Smart Device Development,Smart Devices VB and C# Projects...