我创建了一个在localhost上运行良好的WCF服务,但它在远程计算机上不起作用。它给我一个错误信息:
The type 'BusinessLetters.SqlWebSyncService', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
我的源代码如下。
服务标记文件代码:
<%@ ServiceHost Language="C#" Debug="true" Service="BusinessLetters.SqlWebSyncService" CodeBehind="SqlWebSyncService.svc.cs" %>
代码背后:
namespace BusinessLetters
{
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
[AspNetCompatibilityRequirements(
RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "SqlWebSyncService" in code, svc and config file together.
public class SqlWebSyncService : ISqlWebSyncService
{
}
}
接口:
namespace BusinessLetters
{
[ServiceContract(SessionMode = SessionMode.Required)] // Important attribute
[ServiceKnownType(typeof(SyncIdFormatGroup))]
[ServiceKnownType(typeof(DbSyncContext))]
[ServiceKnownType(typeof(SyncSchema))]
[ServiceKnownType(typeof(WebSyncFaultException))]
[ServiceKnownType(typeof(SyncBatchParameters))]
[ServiceKnownType(typeof(GetChangesParameters))]
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "ISqlWebSyncService" in both code and config file together.
public interface ISqlWebSyncService
{
}
}
Web配置:
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="ValidationSettings:UnobtrusiveValidationMode" value="None" />
</appSettings>
<connectionStrings>
</connectionStrings>
<system.web>
<pages>
</pages>
<httpRuntime maxRequestLength="2000000" />
<compilation debug="true" targetFramework="4.0">
<assemblies>
</assemblies>
</compilation>
<customErrors mode="Off">
<error statusCode="404" redirect="/error.aspx" />
</customErrors>
</system.web>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
<validation validateIntegratedModeConfiguration="false" />
<directoryBrowse enabled="true" />
</system.webServer>
<system.serviceModel>
<protocolMapping>
<add scheme="http" binding="wsHttpBinding"/>
</protocolMapping>
<services>
<service name="BusinessLetters.SqlWebSyncService" behaviorConfiguration="abc">
<endpoint address="" binding="wsHttpBinding"
bindingConfiguration="largeMessageHttpBinding"
contract="BusinessLetters.ISqlWebSyncService">
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<bindings>
<wsHttpBinding>
<binding name="largeMessageHttpBinding" maxReceivedMessageSize="104857600" closeTimeout="00:25:00" openTimeout="00:25:00"
receiveTimeout="00:25:00" sendTimeout="01:50:00">
<readerQuotas maxArrayLength="104857600"/>
<security mode="None" />
<reliableSession enabled="true" />
</binding>
</wsHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="abc">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>
</configuration>
请帮我解决。