Copied connectionstring caused FluentConfigurationException
General August 18th, 2010Today I had a problem with a FluentConfigurationException. The day before I’ve used “the same” configuration and it worked. I just couldn’t understand what’s wrong..
Here’s the exception message: “FluentNHibernate.Cfg.FluentConfigurationException: An
invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.”
But I couldn’t see anything wrong in the configuration:
var config = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2008.ConnectionString(connectionString)
.ProxyFactoryFactory(typeof(NHibernate.ByteCode.LinFu.ProxyFactoryFactory)))
.Mappings(m => m.AutoMappings.Add(AutoMap.AssemblyOf<Customer>(new CrmAutomappingConfiguration())
.Conventions.AddFromAssemblyOf<ColumnNullabilityConvention>()
.UseOverridesFromAssemblyOf<CustomerMappingOverride>()
.IgnoreBase<Entity>));
It’s just a simple fluent nhibernate configuration!!!!
So I debugged and found this connection string: “Data Source=localhost\\sqlexpress;Initial Catalog=TestDB;Integrated Security=SSPI;”
Nothing wrong there I thought… but after a while i saw the double backslash (localhost\\sqlexpress)!!!!!
The day before I had the connection string inside the configuration and the compiler needs the double backslash, but of course that’t not the case when I moved the connectionstring to the app.config.
So I just erased one of the backslashes and everything worked fine.
It remembered me that everything makes a difference. =)
August 19th, 2010 at 13:26
Mitt absolut vanligaste felmeddelande från javautvecklingen i skolan: non-static method cannot be referenced from a static context
Men nu kanske nån kan svara på hur det borde gå till genom att publicera ett lysande exempel!
löstes vanligen genom att prova att göra static till non-static eller tvärtom tills det fungerade
August 19th, 2010 at 13:48
Åsa: This is the best explanation you could get:
http://geekandpoke.typepad.com/geekandpoke/2009/11/the-user-and-the-geek.html
August 20th, 2010 at 09:27
Lol Jens
Åsa, this sounds like the kind of error you can get if you are in a static-method, and on the same class, you try to invoke some other method, which is not static.
Pseudo code:
public class Asa {
public static void f() {
g(); // non-static method cannot be referenced from a static context, buddy!
}
public void g() {
System.out.println();
}
}
Wikipedia ftw: “a method may be declared as static, meaning that it acts at the class level rather than at the instance level. Therefore, a static method cannot refer to a specific instance of the class”.
On the other hand, a non-static member does work on a “specific instance of the class”.
August 20th, 2010 at 16:07
Det är ju lysande Kenneth, det ska jag komma ihåg om en javakod nånsin promenerar förbi i mitt liv igen