流畅的 NHibernate 控制台应用程序
我在一个非常小的控制台应用程序中有以下代码:
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;
}
}
}
一切看起来都很好,按照 Tekpub 上的示例进行操作,但是当我去构建时,我丢失了所有 VS 颜色,并且出现以下错误:
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
我发现这很奇怪,这看起来很奇怪不能工作,但只能在控制台应用程序中工作,因为我让它在另一个更大的项目中工作,我试图将 XML 转换为 Fluent。
有什么想法吗?
编辑这个问题似乎与 VS 2010 有关,如果我尝试在 2008 年构建这个项目,它构建得很好。我仍然想知道为什么它适用于一种而不适用于另一种。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论