Hi,
I am having a strange problem whereby I can access Membership and MembershipUser perfectly from my console application, but accessing Profiles is causing an Exception.
Firstly, I have a reference to System.Web in my project. In my class, I am including System.Web.Wrofile and System.Web.Security.
I wanted to use ProfileCommon, but intellisense does not see this (why not!!?); so I am using ProfileBase in the following way:
ProfileBase userProfile = ProfileBase.Create(mem.UserName, true);
When this line is reached, my try catch gives me:
System.Configuration.ConfigurationErrorsException: Attempting to load this property's type resulted in the following error: Could not load type 'CentralHostLibrary.UserAlertPrefObject' from assembly System.Web...
I don't understand this. Why is it trying to look for my class library (CentralHostLibrary) in System.Web????
Here is my app.config file:
<configuration>
<appSettings>
<add key="ConnectionString" value="Data Source=localhost;Initial Catalog=MembershipDB;Integrated Security=True;"/>
</appSettings>
<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial Catalog=MembershipDB;Integrated Security=True;" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<roleManager enabled="true">
</roleManager>
<membership defaultProvider="AspNetSqlProvider" userIsOnlineTimeWindow="20">
<providers>
<clear/>
<add name="AspNetSqlProvider" type="System.Web.Security.SqlMembershipProvider,
System.Web,
Version=2.0.3600.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="true" minRequiredPasswordLength="8" minRequiredNonalphanumericCharacters="1" passwordFormat="Hashed" description="Stores and retrieves membership data from the local Sql Server database"/>
</providers>
</membership>
<profile defaultProvider="SqlProfileProvider">
<providers>
<remove name="AspNetSqlProfileProvider"/>
<add name="SqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" applicationName="/" connectionStringName="LocalSqlServer"/>
</providers>
<properties>
<add name="FirstName" type="string"/>
<add name="LastName" type="string"/>
<add name="Company" type="string"/>
<add name="AlertPrefs" type="CentralHostLibrary.UserAlertPrefObject" serializeAs="Binary"/>
<add name="PrefsChanged" type="bool" defaultValue="false"/>
</properties>
</profile>
</system.web>
</configuration>