【发布时间】:2011-12-02 10:43:42
【问题描述】:
拜托,我有以下问题:
我正在尝试动态加载 WCF RIA 服务(Silverlight 应用程序的 DDL 和 DAL)。
我有维护授权、身份验证等的主要应用程序。该应用程序是使用 Prism 库实现的——高度模块化,但不幸的是,由于引用了紧密耦合的 RIA 服务库,因此如果不重新编译整个解决方案并导致自动生成代码出现问题,就不可能根据客户要求切换模块。它托管在 IIS (IIS Express) 中。
我要做的是删除主网页应用程序中对自定义模块的引用,动态加载模块并创建必要的端点。
我的第一种方法是在 Web.config 中定义服务:
<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>
问题是,因为它没有被引用,所以没有加载必要的程序集。
然后我尝试在代码中加载程序集,从导出类型 (_types) 列表中获取 DomainServiceType 并使用 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();
这种方法在我之前尝试自托管 RIA 的所有尝试中都失败了:AspNetCompatibilityModeAttribute:
此服务需要 ASP.NET 兼容性,并且必须托管在 IIS 中。在 web.config 中打开 ASP.NET 兼容性的情况下在 IIS 中托管服务,或者将 AspNetCompatibilityRequirementsAttribute.AspNetCompatibilityRequirementsMode 属性设置为必需以外的值。
我试图通过添加来设置域服务的属性
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
但它没有效果。我拼命地用谷歌搜索了很长时间,但没有成功。 您能否就如何加载未引用的 RIA 服务服务器朝正确的方向踢我?
附:我在 Silverlight 5,VS2010
【问题讨论】:
标签: silverlight wcf ria