2011-12-02 88 views
0

請問我有以下問題: 我在嘗試動態加載WCF RIA服務(DDL和DAL for Silverlight應用程序)。
我有主要的應用程序維護授權,身份驗證等。該應用程序是使用Prism庫實現的 - 高度模塊化,但不幸的是,由於引用了RIA服務庫,因此無法根據客戶要求切換模塊,無需重新編譯整個解決方案並導致自動生成的代碼出現問題。它位於IIS(IIS Express)中。
我想要做的是在主網頁應用程序中刪除對自定義模塊的引用,動態加載模塊並創建必要的端點。 我的第一種方法是在Web.config中定義服務:動態主機WCF RIA服務

<services> 
     <service name=PatientRegistry.PatientRegistryDomainService" 
     behaviorConfiguration="RIAServiceBehavior"> 
      <endpoint address="" binding="wsHttpBinding" 
      contract="PatientRegistryDomainService" /> 
      <endpoint address="/soap" 
      binding="basicHttpBinding" 
      contract="PatientRegistryDomainService" /> 
      <endpoint address="/binary" 
      binding="customBinding" 
      bindingConfiguration="BinaryHttpBinding" 
      contract="PatientRegistryDomainService" /> 
     </service> 

    </services> 
    <behaviors> 
     <serviceBehaviors> 
      <behavior name="RIAServiceBehavior"> 
       <serviceMetadata httpGetEnabled="true" /> 
       <serviceDebug includeExceptionDetailInFaults="false" /> 
      </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <bindings> 
     <customBinding> 
      <binding name="BinaryHttpBinding"> 
       <binaryMessageEncoding /> 
       <httpTransport /> 
      </binding> 
     </customBinding> 
    </bindings> 

麻煩的是,因爲它沒有提及,沒有被加載necesary組裝。

然後我試圖加載組件代碼,從出口類型列表獲得DomainServiceType(_types),並使用DomainServiceHost:

Type _svctype = null; 
foreach (Type _T in _types) 
{ 
    if (IsSubclassOfRawGeneric(typeof(DomainService), _T)) 
    { 
     _svctype = _T; 
     break; 
    } 
} 
DomainServiceHost host = new DomainServiceHost(_svctype /*, BaseUri*/); 
host.Open(); 

這種方法失敗的韋裏同樣的問題上selfhosting我以前所有的嘗試RIA:AspNetCompatibilityModeAttribute:
此服務需要ASP.NET兼容性,並且必須託管在IIS中。在web.config中打開ASP.NET兼容性的IIS中託管服務,或者將AspNetCompatibilityRequirementsAttribute.AspNetCompatibilityRequirementsMode屬性設置爲Required以外的值。
我已經嘗試通過增加

[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)] 

設置在域服務的屬性,但它沒有任何效果。我很拼命搜索相當長的一段時間,但沒有成功。 能否請您正確地指導我如何加載未引用的RIA服務服務器?

P.S.我在Silverlight 5中,VS2010

回答

0

你有沒有試過在你的web.config中包含這個?

<system.serviceModel> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> 
</system.serviceModel>