EDIT: I started a closed vote on this question because I resolved the issue. I was doing everything fine, but a reference to an ASP URL rewriter that I downloaded and uninstalled a while ago still had a reference in IIS. This forum post by Waclaw Stypula (the one with the steps) helped me track this down, by accident. When I launched the run command, IIS told me that it (obviously) could not find the rewriter DLL. I removed the reference and the app ran fine after that.
I am following the silverlight.net tutorials by Jesse Liberty. Currently I am trying to do tutorial three, but I am running into a wall under the heading "CREATE THE WEB SERVICE" (about halfway down).
First, when I create the new service by adding it to the solution, the tutorial indicates that three files should be created; IService1.vb
, Service1.svc
, and Service1.svc.vb
. I do not get the IService1.vb
file when I add the service to the solution. I downloaded the copy of the project they provided, and the Service1.svc.vb
file is in there, so I added one manually and copied the contents of the file. The tutorial says it is a VB tutorial, but displays C# in the accompanying screenshot so maybe that is the issue.
After I get all the files made up like the tutorials (copy/paste to make sure I don't have a typo), I try to add the service reference and get the following error:
The service class of type KeyboardControl_Web.Service1 both defines a ServiceContract and inherits a ServiceContract from type KeyboardControl_Web.IService1. Contract inheritance can only be used among interface types. If a class is marked with ServiceContractAttribute, it must be the only type in the hierarchy with ServiceContractAttribute. Consider moving the ServiceContractAttribute on type KeyboardControl_Web.IService1 to a separate interface that type KeyboardControl_Web.IService1 implements.
I tried googling different portions of the message, but did not find much useful information.
Here is the code for the different files:
//IService1.vb
Imports System.ServiceModel
' NOTE: If you change the class name "IService1" here, you must also update
' the reference to "IService1" in Web.config.
<ServiceContract()> _
Public Interface IService1
<OperationContract()> _
Function GetAllLocations() As List(Of Address)
End Interface
//Service1.svc.vb
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Linq
Imports System.Runtime.Serialization
Imports System.ServiceModel
Imports System.Text
' NOTE: If you change the class name "Service1" here, you must also
' update the reference to "Service1" in Web.config and in the
' associated .svc file.
Public Class Service1
Implements IService1
Public Function GetAllLocations() As List(Of Address) Implements IService1.GetAllLocations
Dim db As New DataClasses1DataContext()
Dim matchingCustomers = From cust In db.userControlDemos Select cust
'Return matchingCustomers.ToList()
End Function
End Class
I am new to Silverlight/WCF in general, as well as to Interfaces and Services. Can you guys help me get on the right track?
EDIT: I should add that I am using Visual Studio 2008, on Windows Vista Business SP1.