WCF in a Windows Servers and a Custom Membership Provider.

  • Thread starter Thread starter Tino Donderwinkel
  • Start date Start date
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
 
Tino Donderwinkel said:
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.
SNIPPED

Tino:

I assume you mean the ASP.NET Membership bits? They are tightly coupled to
the HTTP context, but it is possible to use them outside of a web
application. There is one example here:
http://msmvps.com/blogs/theproblemsolver/archive/2006/01/15/81140.aspx

Check the previous entries (1-3) for the entire story. If you need a quick,
down and dirty intro:
http://bit.ly/WalKC

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

********************************************************
| Think outside the box! |
********************************************************
 
Back
Top