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 7643159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:22:41+00:00 2026-05-31T09:22:41+00:00

namespace WcfService1 { // NOTE: You can use the Rename command on the Refactor

  • 0
namespace WcfService1
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
    [ServiceContract]
    public interface HelloWorldService
    {
        [OperationContract]
        [WebGet(UriTemplate = "")]

        public string HelloWorld() //here
        {
            return "Hello world!";
        }
    }
}

I get this error:

Error   1   The modifier 'public' is not valid for this item

This is what I have in my svc.cs file

public class Service1 : HelloWorldService
{
    public string HelloWorld()
    {
        return string.Format("Hello World!");
    }
}

This is actually from a tutorial from my uni:

Unlike last week, where we created interfaces for our services first, we are simply going to create WCF service objects in this first example. This is to save on time within the tutorial. Best practice means that we should be creating interfaces for all our services, which relates to the defined service contract. First of all create a new project within Visual Studio 2008 (remember to add the System.ServiceModel and System.ServiceModel.Web references, and the using declaration for both of these namespaces), and add the following class definition:

[ServiceContract]
public class HelloWorldService
{
[OperationContract]
[WebGet(UriTemplate="")]
public string HelloWorld()
{
return "Hello world!";
}
}

You should be familiar with the basic structure of this WCF service from last week’s tutorial. The difference lies in the extra attribute we have added to the method:
[WebGet(UriTemplate=””)]
This attribute states that the service receives HTTP GET messages (the WebGet part), and that the rest of the URL is not relevant to the service end point (this will become clearer after the later examples). To host this service, we require the following main application:

  • 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-31T09:22:42+00:00Added an answer on May 31, 2026 at 9:22 am

    Members on an interface declaration can’t have an access modifier. They implicitly have the same accessibility as the containing interface. If you can access an interface, you can access all it’s members

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

Sidebar

Related Questions

I place using namespace in a view code behind but i can't call any
Following is the code snippet Server Code : namespace WcfService3 { [ServiceContract] public interface
Namespace are pretty cool: with them, you can organize your libraries and you can
in the System.Linq namespace, we can now extend our IEnumerable's to have the Any()
I have a small namespace containing some type definitions, which I use to make
namespace Dic { public class Key { string name; public Key(string n) { name
namespace std { class type_info { public: virtual ~type_info(); //type_info can serve as a
namespace ns1 { template <class T> void f(T) { cout << typeid(T).name() << endl;
I got many exceptions like: Error 95 The type or namespace name 'Web' does
What namespace do I need to have in my project to execute the command;

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.