Click here to Skip to main content
15,888,323 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have been creating a restful service using WCF.
I had to use serviceroute class in my code and i added the
C#
System.ServiceModel.Activation;

namespace.
Even after using the above namespace it says
C#
The type or namespace name 'ServiceRoute' could not be found


C#
using System.Web.Routing;
using System.Web.Routing.RouteBase;
using System.Web.Routing.Route;
using System.ServiceModel.Web;
using System.ServiceModel.Activation;

namespace RESTfulSample
{
    public class Global : System.Web.HttpApplication
    {
        protected void Application_Start(object sender, EventArgs e)
        { 
            RouteTable.Routes.Add(new ServiceRoute("RestService", new WebServiceHostFactory(), typeof(RESTSerivce))); //ServiceRoute is not found
 
        }
    }
}

Why does it show inspite of using System.ServiceModel.Activation namespace?
?
Posted

1 solution

Before "using" it, you have to have this class in your code; this is your immediate problem. First, the full class name is System.ServiceModel.Activation.ServiceRoute. Second, I'm not sure that you even referenced the assembly where that class is found. This is "System.ServiceModel.Activation.dll": ServiceRoute Class (System.ServiceModel.Activation)[^].

The assembly is in GAC; with Visual Studio, the reference is added from the first tab of the window "Add Reference".

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900