我已經能夠找到許多關於在WPF中使用ASP .NET成員資格提供程序的內容。我甚至有我的WPF應用程序中工作的ASP .NET角色提供程序。這些在WPF中非常容易使用。我找不到任何有關如何在WPF應用程序中使用ASP .NET PROFILE提供程序的信息。在WPF應用程序中使用ASP .NET PROFILE提供程序
我的應用程序將運行在位於移動車輛的筆記本電腦上;它不能使用Web服務來連接到服務器並對用戶進行身份驗證。我的代碼需要能夠從本地數據庫中檢索用戶的配置文件信息。
我已經嘗試了幾次來建立一個派生自ProfileBase的類,但沒有任何我嘗試過的。爲了詳細說明,下面的代碼是從我的最新嘗試失敗的摘錄:
public class UserProfile : ProfileBase {
[CustomProviderData("AlarmsToDisplay;int")]
public int AlarmsToDisplay {
get { return (int) GetPropertyValue("AlarmsToDisplay"); }
set { SetPropertyValue("AlarmsToDisplay", value); }
}
// Other properties following the same pattern follow.
private UserProfile() { }
public static UserProfile GetUserProfile(string username) {
return Create(username) as UserProfile;
}
public static UserProfile GetUserProfile(string username, bool isAuthenticated) {
return Create(username, isAuthenticated) as UserProfile;
}
}
在這段代碼,方法GetUserProfile(用戶名字符串,布爾isAuthenticated)返回null。我相信這是因爲編譯器無法將ProfileBase轉換爲UserProfile,即使UserProfile從ProfileBase中下載。如果我錯了,請糾正我。
有人能指向我現有的文章或描述正確的方式來建立一個從ProfileBase擴展的用戶配置文件類嗎?