Is it possible to use ASP.NET ProfileCommon in a windows service?
-
I have my ProfileCommon Class below
using System.Web.Profile;
public class ProfileCommon : ProfileBase
{
public string LastName
{
get
{
return (string)base["LastName"];
}
set
{
base["LastName"] = value;
this.Save();
}
}public ProfileCommon GetProfile(string userName) { return (ProfileCommon)ProfileBase.Create(userName); }
}
And the Profile section in the windows service app.config file is below
And when i call sample code below
ProfileCommon prf1 = new ProfileCommon();
ProfileCommon prf = prf1.GetProfile("myWindowsLoginName");
string name = prf.LastName;I get an error "Could not load type 'MyWindowsService.Code.ProfileCommon' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'." What am i doing wrong in those sample code snippets? OR is this even the right way of using ProfileCommon in a windows service (.NET 4.0), is this wrong all together, is there a better way. All i want is given a userName, i should get that user's Profile LastName or FirstName from LDAP.
"Coming soon"
-
I have my ProfileCommon Class below
using System.Web.Profile;
public class ProfileCommon : ProfileBase
{
public string LastName
{
get
{
return (string)base["LastName"];
}
set
{
base["LastName"] = value;
this.Save();
}
}public ProfileCommon GetProfile(string userName) { return (ProfileCommon)ProfileBase.Create(userName); }
}
And the Profile section in the windows service app.config file is below
And when i call sample code below
ProfileCommon prf1 = new ProfileCommon();
ProfileCommon prf = prf1.GetProfile("myWindowsLoginName");
string name = prf.LastName;I get an error "Could not load type 'MyWindowsService.Code.ProfileCommon' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'." What am i doing wrong in those sample code snippets? OR is this even the right way of using ProfileCommon in a windows service (.NET 4.0), is this wrong all together, is there a better way. All i want is given a userName, i should get that user's Profile LastName or FirstName from LDAP.
"Coming soon"
devenv.exe wrote:
inherits="MyWindowsService.Code.ProfileCommon"
According to the documentation[^], the
inherits
attribute is a "fully qualified type reference". That means you need to specify the assembly name as well.devenv.exe wrote:
All i want is given a userName, i should get that user's Profile LastName or FirstName from LDAP.
I don't see how the
SqlProfileProvider
is going to load anything from LDAP - it loads and stores the profile properties in SQL. You might have better luck using theSystem.DirectoryServices.AccountManagement
assembly[^] to read this information.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer