2009-12-17 23 views
11

我一直在使用WCF在fx3.5上學習和構建JSONP Web服務。你可以閱讀我在.NET ASMX - Returning Pure JSON?的一些試驗,我終於得到了一個樣本運行,但現在我是我的鴿子拖尾到我的應用程序。無法加載註冊擴展'[extensionHere]'的類型[nameHere]

該服務的web.config文件:

<system.serviceModel> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="JsonpServiceBehavior"> 
      <webHttp /> 
     </behavior> 
     </endpointBehaviors> 
    </behaviors> 
    <services> 
     <service name="RivWorks.Web.Service.CustomerService"> 
     <endpoint address="" 
        binding="customBinding" 
        bindingConfiguration="jsonpBinding" 
        behaviorConfiguration="JsonpServiceBehavior" 
        contract="RivWorks.Web.Service.ICustomerService" /> 
     </service> 
     <service name="RivWorks.Web.Service.NegotiateService"> 
      <endpoint address="" 
        binding="customBinding" 
        bindingConfiguration="jsonpBinding" 
        behaviorConfiguration="JsonpServiceBehavior" 
        contract="RivWorks.Web.Service.INegotiateService" /> 
     </service> 
    </services> 
    <bindings> 
     <customBinding> 
     <binding name="jsonpBinding" > 
      <jsonpMessageEncoding /> 
      <httpTransport manualAddressing="true"/> 
     </binding> 
     </customBinding> 
    </bindings>  
    <extensions> 
     <bindingElementExtensions> 
     <add name="jsonpMessageEncoding" 
      type="RivWorks.Web.Service.JSONP.JsonpBindingExtension 
       , RivWorks.Web.Service 
       , Version=1.0.0.0 
       , Culture=neutral 
       , PublicKeyToken=null"/> 
     </bindingElementExtensions> 
    </extensions> 
    </system.serviceModel> 

我收到以下錯誤,我已經試過所有我能想到的解決它。發現一些拼寫錯誤(服務而不是服務)灑在我的代碼中。我正在使用在MSDN找到的示例代碼。這是錯誤:

Configuration Error Description:** An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. 

Parser Error Message: The type 'RivWorks.Web.Service.JSONP.JsonpBindingExtension 
       , RivWorks.Web.Service 
       , Version=1.0.0.0 
       , Culture=neutral 
       , PublicKeyToken=null' registered for extension 'jsonpMessageEncoding' could not be loaded. 

Source Error: 

Line 58: <customBinding> 
Line 59:  <binding name="jsonpBinding"> 
Line 60:   <jsonpMessageEncoding /> 
Line 61:   <httpTransport manualAddressing="true" /> 
Line 62:  <binding> 

Source File: C:\RivWorks\dev\services\web.config Line: 60 

Version Information: Microsoft .NET Framework Version:2.0.50727.3603; ASP.NET Version:2.0.50727.3082 

有沒有人有什麼我可以檢查的想法?有一個名爲RivWorks.Web.Service.dll的DLL,它正在構建並複製到網站的bin目錄中。服務Web.config正被複制到Web站點的Services目錄中。我在網站的web.config中沒有任何衝突。我檢查了所有拼寫問題。

+0

這絕對不是一個正式的答案,但我只是想分享一些挫折,我有這個確切的問題:在IIS中,我有站點A,它承載應用程序A(App_A)。然後我有一個虛擬目錄託管應用程序B(App_B),也位於站點A. App_A正在實現類似於上述的自定義擴展。 App_B的web.config繼承了App_A的web.config中的這個自定義擴展。這是拋出這裏描述的確切的錯誤。這完全是我的錯,因爲沒有正確配置它。我只是想和大家分享一下。不知道這是否值得回答。 – dyslexicanaboko 2014-05-29 20:30:37

回答

15

生成輸出中的dll(RivWorks.Web.Service.dll)?

接下來,嘗試(對於 「jsonpMessageEncoding」 擴展名):

type="RivWorks.Web.Service.JSONP.JsonpBindingExtension, RivWorks.Web.Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" 

注不同的間隔無論在" , "和回車條款。

之後,我會高音檢查字符串。寫引用您需要的DLL(RivWorks.Web.Service),並輸出一個控制檯EXE:

Console.WriteLine(
    typeof(RivWorks.Web.Service.JSONP.JsonpBindingExtension) 
    .AssemblyQualifiedName); 

也就是說你在XML希望字符串,一字不差。不要在此字符串中包含任何額外的空格。

+0

冉控制檯應用程序和字符串回來,就像我擁有它。捕獲它在一個字符串var,檢查它,複製它,將其粘貼到我的服務web.config中,仍然是相同的錯誤。其他想法? – 2009-12-18 00:03:13

+0

是的,該DLL在構建輸出中。我使用BeyondCompare從我的本地機器項目區域移動到本地主機目錄。此外,它從那裏進入Dev服務器上的Dev目錄(通過BeyondCompare)。我檢查每一步的方式,並且每次都能看到最新的內部版本。 – 2009-12-18 00:14:26

+0

我試着把它全部放在一起,就像你展示的一樣,它沒有任何區別。 :( – 2009-12-18 00:15:07