开发者

Error hosting WCF service in IIS 7.5

开发者 https://www.devze.com 2023-02-20 18:51 出处:网络
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\\ContainerManagementServ

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="ContainerManageme开发者_高级运维ntbasicHttpEndpoint" 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!


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号