C# 将WCF服务从开发人员计算机移动到服务器时出错
这是一个WCF REST服务。该服务在我的开发机器上运行得非常好 我在wwwroot的一个子文件夹中有服务文件,名为Services\ 诚然,我很擅长编写代码,但不太擅长使用IIS托管/发布we服务 我试图做的只是将Services文件夹从我的dev笔记本电脑复制到服务器的wwwroot文件夹 当这种情况发生,我试图访问服务器上的服务时,我会遇到一些奇怪的错误,我不理解(我有点理解它,只是不知道为什么会发生) “找不到作为ServiceHost指令中的服务属性值提供的或在配置元素system.serviceModel/serviceHostingEnvironment/serviceActivations中获益的类型'BooksService.Service1'。” Service1.cs在我的项目中看起来是这样的:C# 将WCF服务从开发人员计算机移动到服务器时出错,c#,.net,web-services,wcf,service,C#,.net,Web Services,Wcf,Service,这是一个WCF REST服务。该服务在我的开发机器上运行得非常好 我在wwwroot的一个子文件夹中有服务文件,名为Services\ 诚然,我很擅长编写代码,但不太擅长使用IIS托管/发布we服务 我试图做的只是将Services文件夹从我的dev笔记本电脑复制到服务器的wwwroot文件夹 当这种情况发生,我试图访问服务器上的服务时,我会遇到一些奇怪的错误,我不理解(我有点理解它,只是不知道为什么会发生) “找不到作为ServiceHost指令中的服务属性值提供的或在配置元素system.s
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中有相当一部分是基于谷歌推荐的,所以我可能不理解某些东西,或者只是把它搞错了
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>***
***
***
我的服务文件如下所示:
然后是一个包含my.dll的bin文件夹
因此,文件夹布局如下所示:
c:\inetpub\wwwroot\SERVICES\BookService\bin
其中service.svc位于BookService文件夹中,程序集位于bin文件夹中
我可能缺少哪些步骤?首先,您需要在IIS中创建一个应用程序,并将虚拟目录指向您的应用程序文件夹:c:\inetpub\wwwroot\SERVICES\BookService 然后,您需要相应地更新您的服务基址:
<baseAddresses>
<add baseAddress="http://localhost/services/bookservice" />
</baseAddresses>
您可以通过在浏览器中键入url并浏览到服务位置来测试url 一,。您确认服务器上安装了相同级别的IIS/.net等吗?2.你有什么安全问题吗?是否有相同的用户/身份运行svc等。这些是需要首先检查的内容感谢您的回复。我知道该服务正在运行IIS 7.0。相对确定的是,dev机器也是如此。对于运行svc的相同用户/身份,您能详细说明一下吗?在我的开发机器上登录和在服务器上登录都是管理员登录。我应该在IIS中配置一些东西来处理这个问题吗?谢谢,我特别想到了谢谢!就是这样。这么简单…我应该看看这个。