I added the WCF Service Application project project to my VS (4.0) solution. Now the default namespace is “ Service ”, and if I run the application (specifying the WCF service application as the startup project), it works fine.
Now I changed the namespace to XXX.YYY.Service.PartnerPortal as under
namespace XXX.YYY.Service.PartnerPortal { public class Service1 : IService1 { public string GetData(int value) { return string.Format("You entered: {0}", value); } } }
In addition to the IService1 interface,
namespace XXX.YYY.Service.PartnerPortal { [ServiceContract] public interface IService1 { [OperationContract] string GetData(int value); } }
I also changed the default namespace in the project properties
The app.config file is under
<?xml version="1.0"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.0"> </compilation> <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/></system.web> <system.serviceModel> <behaviors> <serviceBehaviors> <behavior> <serviceMetadata httpGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="false"/> </behavior> </serviceBehaviors> </behaviors> <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> </system.serviceModel> <system.webServer> <modules runAllManagedModulesForAllRequests="true"> </modules> </system.webServer> </configuration>
And when I try to run the error message that I get,
Error: Can not retrieve metadata from http: // localhost: 65192 / Service1.svc If this is a Windows (R) Communication Foundation service that you have access to, be sure to enable metadata publishing to the specified address. To help enable metadata publishing, refer to the MSDN documentation at http://go.microsoft.com/fwlink/?LinkId=65455.WS-Metadata URI sharing errors: http: // localhost: 65192 / Service1.svc Metadata contains a link which cannot be resolved: "http: // localhost: 65192 / Service1.svc". The server did not give a meaningful response; this may be caused by a contract mismatch, a premature disconnection of the session, or an internal server error. HTTP GET URI error: http: // localhost: 65192 / Service1.svc An error occurred loading "http: // localhost: 65192 / Service1.svc". The request error with the error message: - The type "Service.Service1", provided as the value of the Service attribute in the ServiceHost directive, or provided in the system.serviceModel / serviceHostingEnvironment / serviceActivations configuration item, could not be found. body {font-family: "Verdana"; font-weight: normal; font-size: .7em; color: black;} p {font-family: "Verdana"; font-weight: normal; color: black; margin-top: -5px} b {font-family: "Verdana"; font-weight: bold; color: black; margin-top: -5px} H1 {font-family: "Verdana"; font-weight: normal; font- size: 18pt; color: red} H2 {font-family: "Verdana"; font-weight: normal; font-size: 14pt; color: maroon} pre {font-family: "Lucida Console"; font-size :. 9em} .marker {font-weight: bold; color: black, text-decoration: none;}. version {color: gray;}. error {margin-bottom: 10px;}. expandable {text-decoration: underline; font style: bold; Dark-blue colour; Cursor: hand; }
Server error in application "/".
The type "Service.Service1", provided as the value of the Service attribute in the ServiceHost directive or represented in the configuration element system.serviceModel / serviceHostingEnvironment / serviceActivations, could not be found.
Description: An unhandled exception occurred during the execution of the current web request. View the stack trace for more information about the error and its occurrence in the code.
Exception Details: System.InvalidOperationException: type "Service.Service1" provided as the value of the Service attribute in the ServiceHost directive or provided in the system.serviceModel / serviceHostingEnvironment / serviceActivations configuration item.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack trace:
> [InvalidOperationException: The type 'Service.Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.] System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +51530 System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1461 System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44 System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +651[ServiceActivationException: The service '/Service1.svc' cannot be activated due to an exception during compilation. The exception message is: The type 'Service.Service1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found..] System.Runtime.AsyncResult.End(IAsyncResult result) +688590 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +190 System.ServiceModel.Activation.HostedHttpRequestAsyncResult.ExecuteSynchronous(HttpApplication context, String routeServiceVirtualPath, Boolean flowContext, Boolean ensureWFService) +234 System.ServiceModel.Activation.HttpModule.ProcessRequest(Object sender, EventArgs e) +359 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
Version Information: ÿMicrosoft.NET Framework Version: 4.0.30319; ASP.NET Version: 4.0.30319.272 -.What am I doing and how to fix it?