Sys.Services.ProfileService.save fails

Last post 05-13-2008 3:19 PM by zaphod94. 1 replies.

Sort Posts:

  • Sys.Services.ProfileService.save fails

    05-09-2008, 10:46 AM
    • Loading...
    • zaphod94
    • Joined on 05-09-2008, 10:39 AM
    • Posts 2

    I have setup the profile service to save a custom type to the database. The load, via Sys.Services.ProfileService.load() succeeds. However when I make a change to the loaded object and try to save it via Sys.Services.ProfileService, the custom object is not saved at all. I have stepped through the ProfileService code in System.Web.Extensions and the determined that the conversion of the Json string from the client to my custom type fails. web.config has the required type information like so

    <profile defaultProvider="MyProfileProvider" enabled="true">
          <providers>
            <clear/>
            <add name="MyProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="MyProfile" applicationName="MyApp" />
          </providers>
          <properties>
            <clear/>
            <add name="User" type="MyType, MyType" serializeAs="Binary" allowAnonymous="false" provider="MyProfileProvider" />
          </properties
        </profile>

    What else do I need to configure for the deserializer to figure out the required type info to convert the Json string from the client side to MyType on the server

     TIA

    zaphod 

     

  • Re: Sys.Services.ProfileService.save fails

    05-13-2008, 3:19 PM
    Answer
    • Loading...
    • zaphod94
    • Joined on 05-09-2008, 10:39 AM
    • Posts 2

    OK, finally figured this one out.

    My custom Type did not have a parameterless (default) constructor. If you need to store custom types in the profile database, ensure that the type has a default constructor. Else the Profiles infrastructure will be unable to create an instance of your type and will fail to call the save method.

    Hope this helps someone.

Page 1 of 1 (2 items)