【发布时间】:2014-05-18 23:05:27
【问题描述】:
这是一个 WCF REST 服务。该服务在我的开发机器上运行良好。
我在 wwwroot 的名为 Services\ 的子文件夹中有服务文件
诚然,我很擅长编写代码,但不擅长使用 IIS 来托管/发布我们的服务。
我试图做的只是将服务文件夹从我的开发笔记本电脑复制到服务器的 wwwroot 文件夹。
当发生这种情况并且我尝试访问服务器上的服务时,我收到了一些我不理解的奇怪错误(好吧,我有点理解它只是不知道为什么会这样)
“找不到类型'BooksService.Service1',作为ServiceHost指令中的Service属性值提供,或在配置元素system.serviceModel/serviceHostingEnvironment/serviceActivations中提供。”
Service1.cs 在我的项目中看起来像这样:
namespace BooksService
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
public class Service1 : IDataService
我的 web.config 有相当一部分是基于 google 推荐的,所以我可能不理解某些内容或者只是搞错了。
Web.Config 看起来像:
***<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true"/>
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="BooksService.Service1">
<endpoint address="" binding="webHttpBinding" contract="BooksService.IDataService" behaviorConfiguration="restfulBehavior"/>
<host>
<baseAddresses>
<add baseAddress="http://localhost/bookservice" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="restfulBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information,
set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="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>
</system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>***
我的服务文件如下所示:
然后有一个包含我的 .dll 的 bin 文件夹
所以文件夹布局如下:
c:\inetpub\wwwroot\SERVICES\BookService\bin
service.svc 在 BookService 文件夹中,程序集在 bin 文件夹中。
我可能会遗漏哪些步骤?
【问题讨论】:
-
1.您是否确认服务器上安装了相同级别的 IIS/.net 等? 2.您有任何安全问题吗?运行 svc 等的用户/身份是否相同。这些是首先要检查的内容
-
感谢您的回复。我知道该服务正在运行 IIS 7.0。相对确定开发机器也是如此。关于运行 svc 的相同用户/身份,您能详细说明一下吗?在我的开发机器上登录和在服务器上登录都是管理员登录。我应该在 IIS 中配置什么来解决这个问题吗?
-
谢谢,我特别想的是App Pool identities
标签: c# .net web-services wcf service