System.IO.DirectoryNotFoundException 在 WCF Web 服务中
System.IO.DirectoryNotFoundException In WCF Webservice
我正在创建 WCF Web 服务。所以我在 Github 中得到了一个例子。 Project Example
我能够编译该项目。但是我收到 System.IO.DirectoryNotFoundException 错误。
我的URL是:http://127.0.0.1:8080/v1/HelloService.svc/
我的 IDE:Visual Studio 2019 MAC
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>
根本原因是我们必须在 IIS 中启用 Windows 功能以支持 SVC 扩展。随后,我们可以让这个服务工作。
此外,请注意,在WCF项目中,不需要SVC
文件并不代表ServiceActivations中的相对地址不包含SVC
扩展名。
结果。
相关链接。
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/configuration-based-activation-in-iis-and-was
如果问题仍然存在,请随时告诉我。
我正在创建 WCF Web 服务。所以我在 Github 中得到了一个例子。 Project Example 我能够编译该项目。但是我收到 System.IO.DirectoryNotFoundException 错误。
我的URL是:http://127.0.0.1:8080/v1/HelloService.svc/
我的 IDE:Visual Studio 2019 MAC
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>
根本原因是我们必须在 IIS 中启用 Windows 功能以支持 SVC 扩展。随后,我们可以让这个服务工作。
此外,请注意,在WCF项目中,不需要SVC
文件并不代表ServiceActivations中的相对地址不包含SVC
扩展名。
结果。
相关链接。
https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/configuration-based-activation-in-iis-and-was
如果问题仍然存在,请随时告诉我。