2013-10-10 65 views
1

由於某種原因,我無法通過此錯誤。我已經完成搜索,但找不到任何vb示例。我在做這個web.config錯了什麼?「ServiceHost僅支持類服務類型」

SalesTracking.svc

<%@ ServiceHost Language="VB" Debug="true" Service="SalesTracking.ISalesTracking" CodeBehind="SalesTracking.svc.vb" %> 

SalesTracking.svc.vb

Imports GlobalDir 
Imports System.Web.Script.Serialization 
Imports System.Reflection 
Imports System.Data.SqlClient 
Imports System.Web.Configuration 
Imports System.Threading 
Imports System.ServiceModel.Activation 


<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> _ 
Public Class WebService 
    Implements ISalesTracking 



    Public Function GetDataUsingDataContract(ByVal composite As ClientSideData) As ClientSideData Implements ISalesTracking.GetDataUsingDataContract 

    End Function 
End Class 

的Web.config

<?xml version="1.0"?> 
<configuration> 
    <appSettings/> 
    <connectionStrings> 
     <add name="dbconstring" connectionString="Data Source="" providerName="System.Data.SqlClient" /> 
    </connectionStrings> 
    <system.web> 
     <authentication mode="Windows" /> 
     <authorization> 

      <allow roles="Domain Users" /> 
      <deny users="*" /> 
     </authorization> 
      <customErrors mode="Off"/> 

     <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" /> 

    </system.web> 
    <system.serviceModel> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior name="SalesTracking.WebServiceBehavior"> 
        <!-- 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="true"/> 
       </behavior> 
      </serviceBehaviors> 

      <!-- start addition --> 
      <endpointBehaviors> 
       <behavior name="ServiceAspNetAjaxBehavior" > 
        <enableWebScript/> 
       </behavior> 
      </endpointBehaviors> 
      <!-- end addition --> 

     </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
     <services> 
      <service behaviorConfiguration="SalesTracking.WebServiceBehavior" 
      name="SalesTracking.WebService" > 

       <endpoint address="localhost" behaviorConfiguration="ServiceAspNetAjaxBehavior" 
       binding="webHttpBinding" bindingConfiguration="NewBinding0" name="SalesTracking.WebService" 
       contract="SalesTracking.ISalesTracking"> 
       </endpoint> 
       <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
      </service> 
     </services> 

    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 

</configuration> 
+0

我編輯了您的標題。請參閱:「[應該在其標題中包含」標籤「](http://meta.stackexchange.com/questions/19190/)」,其中的共識是「不,他們不應該」。 –

回答

9

Service屬性必須是實現的,而不是接口。

<%@ ServiceHost Language="VB" Debug="true" Service="SalesTracking.WebService" .... 
+0

謝謝先生! – atrueresistance

+0

當我重命名服務時,這個問題剛剛發生在我身上。顯然,dident會影響svc文件,所以在改變之後就像你說的那樣,它像一個魅力:)。 – JensB

+0

謝謝你..我爲我工作.... –

相關問題