Saturday, March 19, 2011

Kindle: We were unable to download the book... please try again later

A few days ago I installed Kindle on my Mac Book Pro, then only after a couple days of using it I suddenly got this error and was not able to open any of the two books I had just bought, I was able to open the books just fine on my iPhone and iPad, but the Kindle for Mac kept giving me this error message no matter how many times I tried clicking; a search on Google gave me 3 results and no solutions, so I uninstalled the App and reinstalled, got nothing. I tried the Tools menu, manage your Kindle from the Kindle app which takes you to the amazon site, noticed the "your orders" at the bottom and the options to download the content, tried that a few times, still nothing, another thing I noticed on the Kindle app was that the title was something like "???????????????? Home", I knew something was messed up bad, but even reinstalling didn't fix it, so in one last desperate attempt I checked out the Kindle preferences [Command]+, or under the Kindle menu, preferences, I clicked the only button there: "Deregister", agreed to the warning and selected "remove all licensed content from this device" and clicked "deregister" again on the warning window; a register button then showed up, I clicked it to register the app again, had to agree to some other warning, and that right there was the solution, I was able to get my books (had to download them again) and start reading, so I'm just leaving this out there in hopes it can help someone else; long story short, deregister the app, make sure to select "remove all licensed content from this device", then register again.

Wednesday, March 02, 2011

FluentNHibernate: "unable to locate persister:"

There's quite a bit of info out there for this error message, but all I could find refers to xml configuration, the recommendation being somewhere along the lines of:

  1. Make sure your mapping file is named *.hbm.xml
  2. Make sure it is set to an embedded resource.
  3. If all else fails, debug.

What most articles fail to mention is the root cause, which is the fact that NHibernate was not able to load the mappings for the class you are trying to use in your query, knowing that you can at least focus in a single area, in the case of fluent nhibernate, the configuration looks something like this:

public static ISessionFactory CreateSessionFactory() {
   return Fluently.Configure()
   .Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey("AppDb")))
   .Mappings(m => m.FluentMappings.Add<ProductMap>())
   .Mappings(m => m.FluentMappings.Add<CategoryMap>())
   .ExposeConfiguration(c => c.SetProperty("current_session_context_class", "web"))

The two .Mappings() lines are the bug in this case, any subsequent calls to it override the first one and you won't be able to query Products
There are two ways of fixing this, one you can tell it to load all the mappings found on the same assembly as the first map

   .Mappings(m => m.FluentMappings.AddFromAssemblyOf<ProductMap>())

or if you want to be specific:

   .Mappings(m => { m.FluentMappings.Add<ProductMap>();
                    m.FluentMappings.Add<CategoryMap>(); })

Hope someone else finds this helpful