Please, I have the following problem:
I’m trying to dynamically load a WCF RIA service (DDL and DAL for Silverlight app).
I have main application maintaining authorization, authentication and so on. The app is implemented using Prism libraries – highly modular, but unfortunately because of referencing the RIA service library tihgtly coupled, so it is impossible to switch modules depending on customers requirements without recompiling whole solution and causing trouble with autogenerated code. It is hosted in IIS (IIS Express).
What I’m trying to do is to remove the reference to custom module in the main Webpage app, load the module dynamically and create necesary endpoints.
My first approach was to define the service in 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>
Trouble was, that because it wasn’t referenced, the necesary assembly wasn’t loaded.
Then I tried to load the assembly in code, get the DomainServiceType from list of exported types (_types) and use 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();
This approach failed on the wery same trouble all my previous attempts on selfhosting RIA: AspNetCompatibilityModeAttribute:
This service requires ASP.NET compatibility and must be hosted in IIS. Either host the service in IIS with ASP.NET compatibility turned on in web.config or set the AspNetCompatibilityRequirementsAttribute.AspNetCompatibilityRequirementsMode property to a value other than Required.
I’ve tried to set the attribute on the domain service by adding
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
but it had no effect. I’m quite desperately googling for quite a long time, but to no success.
Could you please kick me in the right direction on how to load unreferenced RIA service server?
P.S. I’m on Silverlight 5, VS2010
Have you tried to include this in your web.config?