WCF Web服务中的System.IO.DirectoryNotFoundException

问题描述 投票:0回答:1

我正在创建WCF Web服务。所以我在Github上有个例子。Project Example我能够编译该项目。但是我收到System.IO.DirectoryNotFoundException错误。

我的网址是:http://127.0.0.1:8080/v1/HelloService.svc/

我的IDE:Visual Studio 2019 MAC

enter image description here

web.xml

<?xml version="1.0"?>
<configuration>

<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5"/>
</system.web>
<system.serviceModel>
<behaviors>
  <serviceBehaviors>
    <behavior>
      <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<protocolMapping>
    <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
  <serviceActivations>
    <add relativeAddress="v1/HelloService.svc"
         service="FilelessActivation.Services.HelloServiceImpl"
         factory="System.ServiceModel.Activation.ServiceHostFactory" />
  </serviceActivations>
</serviceHostingEnvironment>
<services>
  <service name="FilelessActivation.Services.HelloServiceImpl">
    <endpoint binding="basicHttpBinding" 
              bindingNamespace="http://oscarkuo.com/v1/hello" 
              contract="FilelessActivation.Services.IHelloService" />
  </service>  
</services> 
</system.serviceModel>
<system.webServer>
 <modules runAllManagedModulesForAllRequests="true"/>
  <directoryBrowse enabled="true"/>
</system.webServer>

</configuration>
wcf visual-studio-mac
1个回答
0
投票

根本原因是我们必须启用Windows功能才能在IIS中支持SVC扩展。随后,我们可以使该服务正常工作。enter image description here此外,请注意,在WCF项目中,不需要SVC文件并不表示ServiceActivations中的相对地址不包含SVC扩展名。结果。enter image description here相关链接。https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/configuration-based-activation-in-iis-and-was请随时让我知道问题是否仍然存在。

© www.soinside.com 2019 - 2024. All rights reserved.