T
Tino Donderwinkel
Hi,
I have a Windows Service that hosts a WCF Service. I want to an old
Membership Provider I made some time ago to do the authentication for this
WCF Service.
E.g.
protected override void OnStart(string[] args)
{
public ServiceHost serviceHost = new
ServiceHost(typeof(My.WCF.Service));
serviceHost.Open();
}
I do not want to use IIS to host the WCF Service. I really want to be
running it inside the Windows Service.
I have configured stuff like this in the services' app.config:
<configuration>
<connectionStrings>
<add name="SqlConnection" connectionString="..."
providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.serviceModel>
<services>
<service name="My.WCF.Service" behaviorConfiguration="ServiceBehavior" >
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/CoreServices/Service" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract
="My.WCF.Contract" bindingConfiguration="MembershipBinding" />
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="True" policyVersion="Policy15"
/>
<serviceDebug includeExceptionDetailInFaults="True"/>
<serviceCredentials>
<userNameAuthentication
userNamePasswordValidationMode="MembershipProvider"
membershipProviderName="MyMembershipProvider"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="MembershipBinding">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
<system.web>
<membership defaultProvider="MyMembershipProvider"
userIsOnlineTimeWindow="15">
<providers>
<clear />
<add
name="MyMembershipProvider"
type="My.WCF.MembershipProvider"
connectionStringName="SqlConnection"
applicationName="Service"
enablePasswordRetrieval="false"
enablePasswordReset="false"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true"
passwordFormat="Clear" />
</providers>
</membership>
</system.web>
</configuration>
I thought that would be a nice try. But now, when I want to start the
Windows Service I get the dreaded System.TypeLoadException on
'My.WCF.MembershipProvider'. (System.Web, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a.)
The same provider DOES work under IIS with a WCF service.
Is it possible to use the membership provider without hosting the app in
IIS? If so, any ideas what I'm missing here?
Thanks,
Tino
I have a Windows Service that hosts a WCF Service. I want to an old
Membership Provider I made some time ago to do the authentication for this
WCF Service.
E.g.
protected override void OnStart(string[] args)
{
public ServiceHost serviceHost = new
ServiceHost(typeof(My.WCF.Service));
serviceHost.Open();
}
I do not want to use IIS to host the WCF Service. I really want to be
running it inside the Windows Service.
I have configured stuff like this in the services' app.config:
<configuration>
<connectionStrings>
<add name="SqlConnection" connectionString="..."
providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.serviceModel>
<services>
<service name="My.WCF.Service" behaviorConfiguration="ServiceBehavior" >
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/CoreServices/Service" />
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract
="My.WCF.Contract" bindingConfiguration="MembershipBinding" />
<endpoint address="mex" binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="True" policyVersion="Policy15"
/>
<serviceDebug includeExceptionDetailInFaults="True"/>
<serviceCredentials>
<userNameAuthentication
userNamePasswordValidationMode="MembershipProvider"
membershipProviderName="MyMembershipProvider"/>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="MembershipBinding">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"/>
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
<system.web>
<membership defaultProvider="MyMembershipProvider"
userIsOnlineTimeWindow="15">
<providers>
<clear />
<add
name="MyMembershipProvider"
type="My.WCF.MembershipProvider"
connectionStringName="SqlConnection"
applicationName="Service"
enablePasswordRetrieval="false"
enablePasswordReset="false"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="true"
passwordFormat="Clear" />
</providers>
</membership>
</system.web>
</configuration>
I thought that would be a nice try. But now, when I want to start the
Windows Service I get the dreaded System.TypeLoadException on
'My.WCF.MembershipProvider'. (System.Web, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a.)
The same provider DOES work under IIS with a WCF service.
Is it possible to use the membership provider without hosting the app in
IIS? If so, any ideas what I'm missing here?
Thanks,
Tino