Dot-Net

方式姓名H___呃__n一種米和H和r和nameHere註冊擴展 ’extensionH呃__和X噸和ns一世這nH和r和extensionHere’ 無法載入

  • December 29, 2012

我一直在學習和建構在 fx3.5 上使用 WCF 的 JSONP Web 服務。您可以閱讀我在.NET ASMX - Returning Pure JSON? 我終於執行了一個範例,但現在我正在將它尾隨到我的應用程序中。

服務的 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.config 中沒有任何衝突。我檢查了所有拼寫問題。

建構輸出中是否包含 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 的控制台 exe (RivWorks.Web.Service),然後輸出:

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

那是您在 xml 中想要的字元串,逐字逐句。不要在此字元串中包含任何額外的空格。

引用自:https://stackoverflow.com/questions/1925268