请问我有以下问题: 我在尝试动态加载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