我正在运行MVC3和Windows身份验证Web应用程序.当我部署到IIS6时,它运行良好,直到我点击需要身份验证的页面.然后,当我在我的应用程序中没有跟踪它并且我的web.config配置为windows auth时,它会自动重定向到/ Account/Login.
有任何想法吗?
这是我的整个web.config文件:http://pastie.org/1568510
asp.net-mvc iis-6 windows-authentication sharp-architecture asp.net-mvc-3
当你在流畅的NHibernate中设置字符串值时,它会将数据库值设置为Nvarchar(255),我需要存储相当多的基于用户输入的长字符串,而255是不切实际的.
只是为了添加这个是自动播放器的问题,因为我使用流畅的NHibernate来构建数据库.
c# nhibernate fluent-nhibernate automapping sharp-architecture
我刚刚下载了sharparchitecture/Northwind,我正在努力让crud脚手架工作.除了添加对此类库的缺少引用之外,我什么都没做.我尝试运行ScaffoldingGeneratorCommand.tt,然后点击3个错误.
错误1编译转换:类,结构或接口成员声明文件中的标记'this'无效:BaseTemplate.tt
错误2编译转换:类,结构或接口方法必须具有返回类型文件:BaseTemplate.tt
错误3编译转换:键入预期文件:BaseTemplate.tt
编译器说它们出现在BaseTemplate.tt的第一行,但我不认为这是真正的原因.
有人有这个问题吗?你知道我该怎么做才能解决它吗?
非常感谢你的时间,PK
每当我的S#arp架构尝试启动时,我都会收到此错误,这是SQL Server的一个问题(例如:SQL Server没有运行),在启动SQL Server并点击刷新后,我收到此错误:
已为此应用程序配置了存储机制
这对我来说已经存在于3个项目中的问题.
我尝试过以下方法:
<property name="connection.isolation">ReadCommitted</property>
Run Code Online (Sandbox Code Playgroud)
在hibernate.cfg.xml中设置
使用流利的nhiberate:
MsSqlConfiguration.MsSql2008.IsolationLevel(IsolationLevel.ReadCommitted);
Run Code Online (Sandbox Code Playgroud)
在global.asax.cs中设置
我总是被迫这样设置:
CurrentNhibernateSession.Transaction.Begin(IsolationLevel.ReadCommitted);
Run Code Online (Sandbox Code Playgroud)
哪个有效.(我可以使用NHibernate Profiler看到这个)
问题是现在我使用的是尖锐的架构,并且在该框架内调用了transaction.begin,我在重建它时遇到了麻烦.
有没有办法做到这一点,无需在开始交易时明确设置它?
我正在玩Sharp Architecture Lite,它强调约定优于配置,并试图理解NHibernate的ConventionModelMapper工作原理.具体来说,我无法区分下面的IsRootEntity和IsEntity方法(BTW,Entity是Sharp Arch附带的抽象类):
internal static class Conventions
{
public static void WithConventions(this ConventionModelMapper mapper, Configuration configuration) {
Type baseEntityType = typeof(Entity);
mapper.IsEntity((type, declared) => IsEntity(type));
mapper.IsRootEntity((type, declared) => baseEntityType.Equals(type.BaseType));
public static bool IsEntity(Type type) {
return typeof(Entity).IsAssignableFrom(type)
&& typeof(Entity) != type
&& !type.IsInterface;
}
}
Run Code Online (Sandbox Code Playgroud)
我知道该IsEntity方法用于告诉NHibernate哪些类符合数据库的映射/持久性.但是,我不能为我的生活弄清楚IsRootEntity方法的作用.周围的文档ConventionModelMapper非常稀少.
nhibernate nhibernate-mapping convention-over-configur sharp-architecture
我有一个控制台应用程序c#项目依赖于NHibernate 3.3.2和ShapArch.NHibernate 2.0.4.628,它已经用NHibernate 3.3.1编译(据我所知 - 我可能错了,但是当我创建了一个2.0.4时SharpArch项目它通过Nuget下载了NH 3.3.1.
当引用的dll为3.3.2.4000时,为什么Visual Studio将NHibernate显示为版本3.3.1.4000?对于所有引用,"特定版本"属性都设置为false.SharpArch的版本出现在VS 2.0.0.0而不是2.0.4,这是文件/产品版本.
在app配置中我有:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.3.1.4000" newVersion="3.3.2.4000" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
该应用无法加载:
System.IO.FileLoadException was unhandled
Message=Could not load file or assembly 'NHibernate, Version=3.3.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source=MyApp.ResourcesGenerator
FileName=NHibernate, Version=3.3.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
FusionLog=""
StackTrace:
at MyApp.ResourcesGenerator.Program.InitializeNHibernateSession()
at SharpArch.NHibernate.NHibernateInitializer.InitializeNHibernateOnce(Action initMethod) in d:\Builds\SharpArch2\Solutions\SharpArch.NHibernate\NHibernateInitializer.cs:line 54
at MyApp.ResourcesGenerator.Program.Initialize() in C:\projects\tc\Trunk\Source_LibsUpgrade\Applications\PerformanceManagement\MyApp.ResourcesGenerator\Program.cs:line …Run Code Online (Sandbox Code Playgroud) CQRS和CRUD有什么不同,我可以在两种情况下使用UnitOfWork和Repository模式吗?
如果我推荐给你的那个人之间有一个复杂的关系,为什么?
CQRS模式:http ://martinfowler.com/bliki/CQRS.html
CRUD:http://en.wikipedia.org/wiki/Create,_read,_update_and_delete
任何帮助将不胜感激.
architecture entity-framework architectural-patterns sharp-architecture
我有一个S#arp架构应用程序,它实现了一个轻量级的队列处理工具,各种线程从列表中提取实体并设置其状态以标记处理已在这些项上启动的事实.
尽管将开始处理位包装在显式事务中并使用C#lock(),但我仍然有时会在同一时间启动它们.
我后悔没有使用MSMQ ......好吧,是的,但现在这种并发行为让我感到困惑.很明显,我对NHibernate事务和刷新有些不了解.你能帮我吗?
这是相关的代码:
private static object m_lock = new object();
private bool AbleToStartProcessing(int thingId)
{
bool able = false;
try
{
lock (m_lock)
{
this.thingRepository.DbContext.BeginTransaction();
var thing = this.thingRepository.Get(thingId);
if (thing.Status == ThingStatusEnum.PreProcessing)
{
able = true;
thing.Status = ThingStatusEnum.Processing;
}
else
{
logger.DebugFormat("Not able to start processing {0} because status is {1}",
thingId, thing.Status.ToString());
}
this.thingRepository.DbContext.CommitTransaction();
}
}
catch (Exception ex)
{
this.thingRepository.DbContext.RollbackTransaction();
throw ex;
}
if (able)
logger.DebugFormat("Starting processing of {0}",
thingId);
return able;
}
Run Code Online (Sandbox Code Playgroud)
我原以为这可以保证只有一个线程可以同时改变"事物"的状态,但我会在我的日志中定期得到这个: …
我对这些技术还很陌生.这里真正的问题是如何在控制台应用程序中管理每个线程的会话.目前,如果我将它作为单个线程运行,那么一切都很顺利.一旦我切换到多线程模型,我将开始在会话级别看到争用(因为Session对象不是设计上的安全性)KeyNotFound异常(以及其他)开始被抛出.
在Web应用程序中,您可以执行以下操作:
/// <summary>
/// Due to issues on IIS7, the NHibernate initialization cannot reside in Init() but
/// must only be called once. Consequently, we invoke a thread-safe singleton class to
/// ensure it's only initialized once.
/// </summary>
protected void Application_BeginRequest(object sender, EventArgs e)
{
NHibernateInitializer.Instance().InitializeNHibernateOnce(
() => InitializeNHibernateSession());
}
/// <summary>
/// If you need to communicate to multiple databases, you'd add a line to this method to
/// initialize the other database as well.
/// </summary> …Run Code Online (Sandbox Code Playgroud) 我使用S#arp架构,它使用Windsor Castle作为IoC.我现在有一个新的控制器,与项目中的所有其他控制器不同,需要不同的相同接口实现.即所有控制器都使用ProductsRepository:IProductsRepository作为实现,但新的控制器必须使用SpecificProductsRepository.
如何将其配置为自动识别和管理?无论是纯粹的Windsor方式,还是ASP.NET MVC帮助(例如在我的自定义控制器工厂中).
好像我需要子容器.仍在搜索中.
我在ASP.NET MVC 3应用程序中使用SharpArchitecture.一切都很美妙.
使用SharpArchitecture的NHibernateInitializer为每个请求初始化一个新的Session,如下所示:
protected void Application_BeginRequest(object sender, EventArgs e)
{
NHibernateInitializer.Instance().InitializeNHibernateOnce(InitializeNHibernateSession);
}
private void InitializeNHibernateSession(ISessionStorage sessionStorage)
{
NHibernateSession.ConfigurationCache = new NHibernateConfigurationFileCache(
new[] { "App.Core" });
NHibernateSession.Init(
sessionStorage,
new[] { Server.MapPath("~/bin/" + ApplicationSettings.Instance.NHibernateMappingAssembly) },
new AutoPersistenceModelGenerator().Generate(),
Server.MapPath("~/NHibernate.config"));
NHibernateSession.AddConfiguration(ApplicationSettings.NHIBERNATE_OTHER_DB,
new[] { Server.MapPath("~/bin/" + ApplicationSettings.Instance.NHibernateMappingAssembly) },
new AutoPersistenceModelGenerator().Generate(),
Server.MapPath("~/NHibernateForOtherDb.config"), null, null, null);
}
Run Code Online (Sandbox Code Playgroud)
如您所见,我们也在访问多个数据库.一切都很好.
这是我遇到问题的地方.
我需要启动一个单独的线程来执行数据库轮询机制.我的意图是做这样的事情:
protected void Application_Start()
{
....
ThreadingManager.Instance.ExecuteAction(() =>
{
// initialize another NHibernateSession within SharpArchitecture somehow
NHibernateInitializer.Instance().InitializeNHibernateOnce(InitializeNHibernateSession);
var service = container.Resolve<IDatabaseSynchronizationService>();
service.SynchronizeRepositories();
});
}
Run Code Online (Sandbox Code Playgroud)
通过我的SynchronizationService,一些存储库被调用.显然,当他们尝试访问其会话时,会抛出异常,因为Session为null.
这是我的问题.我如何利用SharpArchitecture的NHibernateSession并以某种方式获得它或它的副本,在我的轮询线程中旋转?我希望这可以在不必绕过使用SharpArchitecture使用的内置SessionManagers和SessionFactories的情况下完成.
nhibernate ×8
asp.net-mvc ×3
c# ×3
.net ×1
architecture ×1
automapping ×1
c#-4.0 ×1
concurrency ×1
iis-6 ×1
northwind ×1
sql-server ×1
t4 ×1