简体   繁体   中英

Error hosting WCF service in IIS 7.5

I have a WCF service that I would like to host in IIS 7.5. My setup: The physical path of the folder with .svc file is: C:\\inetpub\\wwwroot\\SmartSolution\\Services\\Services\\ContainerManagementService.svc My binaries are in C:\\inetpub\\wwwroot\\SmartSolution\\Services\\bin

I have created a web application in IIS for both Services folders.

Here is the config file for the WCF endpoint:

      <service behaviorConfiguration="MyNamespace.ContainerManagementServiceBehavior"
    name="MyNamespace.ContainerManagementService">
    <endpoint address="" binding="basicHttpBinding"
       name="ContainerManagementbasicHttpEndpoint" contract="MyNamespace.IContainer"/>                  
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>      
   <behaviors>      
    <behavior name="MyNamespace.ContainerManagementServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
</behaviors>

Here is my .svc file makrkup:

<%@ ServiceHost Language="C#" Debug="true" Service="MyNamespace.ContainerManagementService" CodeBehind="ContainerManagementService.svc.cs" %>

When I try to navigate to: http://localhost/SmartSolution/Services/Services/ContainerManagementService.svc , the following error is displayed:

The type 'MyNamespace.ContainerManagementService', provided as the Service attribute value in the ServiceHost directive could not be found.

How can I get the service to work. Thanks!

If your site is precompiled and you already have the binaries (containing the MyNamespace.ContainerManagementService ) in the bin folder you don't need to specify a CodeBehind attribute:

<%@ ServiceHost 
    Language="C#"    
    Debug="true" 
    Service="MyNamespace.ContainerManagementService" 
%>

If on the other hand your site is not precompiled and you have shipped the source code as well this source code need to be in the special ~/App_Code folder.

IIS is expecting your bin folder to be in the same folder as your .svc file, but it appears that you have it placed in the parent folder.

Also, you should only need the one application specified in IIS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM