Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7429797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:02:05+00:00 2026-05-29T09:02:05+00:00

I have a Silverlight project that uses a WCF service that I created. My

  • 0

I have a Silverlight project that uses a WCF service that I created. My problem is that in my WCF service, I created a ServiceHost but VS2010 doesn’t seem to recognize the instance of my object (underlines the svHost). Below is the code for my service.

using System;
using System.Collection.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ServiceModel.Activation;

namespace userIO.Web
{
     [ServiceContract]
     public class CoordsService
     {
         [OperationContract]
         public double xDir();
         [OperationContract]
         public double yDir();
         [OperationContract]
         public String keyPressed();

         public class Coords : CoordsService
         {
             public double xDir { get; set; }
             public double yDir { get; set; }
             public String keyPressed { get; set; }
         }

         ServiceHost svHost = new ServiceHost(typeof(Coords), new Uri("http://localhost:8080"));
         BasicHttpBinding binding = new BasicHttpBinding();
         svHost.AddServiceEndpoint(typeof(CoordsService), binding, "");
         svHost.Open();
     }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T09:02:06+00:00Added an answer on May 29, 2026 at 9:02 am

    Your ServiceContract should decorate an interface (a contract). The ServiceHost should host an instance of this interface and be outside the same service that it’s hosting. At least I’ve only seen it done in this way.

    The basic structure is:

    [ServiceContract]
    public interface IService
    {
         [OperationContract]
         void DoSomething(Data data);
    }
    
    [DataContract]
    public class Data
    {
         [DataMember]
         int Num {get;set;}
    }
    
    public class Service : IService
    {
        public void DoSomething(Data data)
        {  // do something }
    }
    
    // run in any other kind of app, console, win service, winform/wpf
    static void Main()
    {
             ServiceHost svHost = new ServiceHost(typeof(Service), new Uri("http://localhost:8080"));
             BasicHttpBinding binding = new BasicHttpBinding();
             svHost.AddServiceEndpoint(binding, "");
             svHost.Open();
    
    }
    

    An even easier solution to get your service up and running in VS2010 is to just create the service in a new WCF Service template. Take out their demo code, put in your own code for the servicecontract interface and the implementation service, then choose debug -> run and VS2010 will host the service for you without having to create an external app to run the service. Will also let you send data to the service to test out the code and the return values of your wcf functions in their simple winforms app.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Silverlight 2 appliction, that uses a WCF service. The service
I have a silverlight application that uses wcf service. This application is shown from
I have a silverlight 4 project that uses wcf ria services to connect to
I have a Silverlight 4 user control that calls a WCF service residing within
I am working on a Silverlight application that uses WCF. I need to have
This might be a bit tricky setup but... I have this Silverlight project that
I recently inherited a Silverlight web project that uses WCF services to handle asynchronous
I have a Silverlight project that uses MVVM with Prism. I followed http://www.telerik.com/help/silverlight/patterns-and-practices-eventtocommand-prism.html I
I have a Silverlight project calling a WCF service. The service method GetData has
We have a silverlight project that uses RIA services. There is some code that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.