I Have the Following Code in a VERY small Console App:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
namespace test
{
class Program
{
static void Main(string[] args)
{
var factory = CreateSessionFactory();
var session = factory.OpenSession();
Console.Write("done");
Console.Read();
}
static ISessionFactory CreateSessionFactory()
{
string csStringName = Environment.MachineName;
var cfg = Fluently.Configure()
.Database(MsSqlConfiguration.MsSql2005
.ConnectionString(c => c.FromConnectionStringWithKey(csStringName)))
.Mappings(m => m.FluentMappings.AddFromAssembly(Assembly.GetAssembly(typeof(StatusCode))))
.BuildSessionFactory();
return cfg;
}
}
}
Everything looks fine, following along on example on Tekpub, however when I go to build I loose all the VS colors and I get the following Errors:
Error 1 The type or namespace name 'FluentNHibernate' could not be found (are you missing a using directive or an assembly reference?) C:\PROJECTS TEST\test\test\Program.cs 6 7 test
Error 2 The type or namespace name 'FluentNHibernate' could not be found (are you missing a using directive or an assembly reference?) C:\PROJECTS TEST\test\test\Program.cs 7 7 test
Error 3 The type or namespace name 'NHibernate' could not be found (are you missing a using directive or an assembly reference?) C:\PROJECTS TEST\test\test\Program.cs 8 7 test
Error 4 The type or namespace name 'ISessionFactory' could not be found (are you missing a using directive or an assembly reference?) C:\PROJECTS TEST\test\test\Program.cs 21 16 test
I find it so strange that this seems not to work but ONLY when inside a Console App as I have it working in another larger project that I am attempting to convert from XML to Fluent.
Any Ideas ?
EDIT the issue seems to be something to do with VS 2010 if I attempt to build this project in 2008 it builds fine. I would still like to know why it would work in one and not the other.