Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Is it possible to use ASP.NET ProfileCommon in a windows service?

Is it possible to use ASP.NET ProfileCommon in a windows service?

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelpquestionannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    devenv exe
    wrote on last edited by
    #1

    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"

    Richard DeemingR 1 Reply Last reply
    0
    • D devenv exe

      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"

      Richard DeemingR Offline
      Richard DeemingR Offline
      Richard Deeming
      wrote on last edited by
      #2

      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 the System.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

      "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups