AR Error "WebThreadScopeInfo: Could not access HttpContext.Current"

245 views
Skip to first unread message

Gabriel Mancini de Campos

unread,
Mar 6, 2009, 9:30:44 AM3/6/09
to Castle Project Users
Hi evey one,

I Have this senario,
When the user abandon my application, i need do some updates in my
base. in this moment show me this error.

My Confis is in a object, because i need change some configurations
in run-time.

in Web.config

<add name="ar.sessionscope"
type="Castle.ActiveRecord.Framework.SessionScopeWebModule,
Castle.ActiveRecord"/>
--this is the only configuration of ar in my web.config

in Global.asax

protected void Application_Start(object sender, EventArgs e)
{
ActiveRecordStarter.Initialize(ARConfig.GetArAssembys(),
ARConfig.GetArSource());
}


public class ARConfig
{
public static Assembly[] GetArAssembys()
{
return new Assembly[] { Assembly.Load("Sof.Log"),
Assembly.Load("ChatManager.Model"), Assembly.Load("Exceller.Context"),
Assembly.Load("ControleAcesso.Model") };
}

public static InPlaceConfigurationSource GetArSource()
{
InPlaceConfigurationSource source = new
InPlaceConfigurationSource
{
ThreadScopeInfoImplementation = typeof
(HybridWebThreadScopeInfo),
IsRunningInWebApp = true,
VerifyModelsAgainstDBSchema = true
};


source.Add(typeof(ActiveRecordBase), new
Dictionary<string, string>
{

{"connection.driver_class","NHibernate.Driver.SqlClientDriver"},
{"dialect",
"NHibernate.Dialect.MsSql2000Dialect"},

{"connection.provider","NHibernate.Connection.DriverConnectionProvider"},

{"connection.connection_string", "Password=1234;Persist Security
Info=True;User ID=chatdbuser;Initial Catalog=ChatManager;Data
Source=sofdb1;Min Pool Size=5;Max Pool Size=100;Connect Timeout=60;"},

{"proxyfactory.factory_class",
"NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle"},
}); // Framework
(LOG)

source.Add(typeof(ChatBaseModel<,>), new
Dictionary<string, string>
{

{"connection.driver_class","NHibernate.Driver.SqlClientDriver"},
{"dialect",
"NHibernate.Dialect.MsSql2000Dialect"},

{"connection.provider","NHibernate.Connection.DriverConnectionProvider"},

{"connection.connection_string", "Password=1234;Persist Security
Info=True;User ID=chatdbuser;Initial Catalog=ChatManager;Data
Source=sofdb1;Min Pool Size=5;Max Pool Size=100;Connect Timeout=60;"},

{"proxyfactory.factory_class",
"NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle"},
}); // Chat

source.Add(typeof(ExcellerContextBaseModel<>), new
Dictionary<string, string>
{

{"connection.driver_class","NHibernate.Driver.SqlClientDriver"},

{"dialect", "NHibernate.Dialect.MsSql2000Dialect"},

{"connection.provider","NHibernate.Connection.DriverConnectionProvider"},

{"connection.connection_string", "Password=1234;Persist Security
Info=True;User ID=chatdbuser;Initial Catalog=ChatManager;Data
Source=sofdb1;Min Pool Size=5;Max Pool Size=100;Connect Timeout=60;"},

{"proxyfactory.factory_class",
"NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle"},
}); //
Botao e Acesso


source.Add(typeof(ControleAcessoBaseModel<>), new
Dictionary<string, string>
{

{"connection.driver_class","NHibernate.Driver.SqlClientDriver"},

{"dialect", "NHibernate.Dialect.MsSql2000Dialect"},

{"connection.provider","NHibernate.Connection.DriverConnectionProvider"},

{"connection.connection_string", "Password=sofdbuser;Persist Security
Info=True;User ID=sofdbuser;Initial Catalog=SOF_EXC_PRD_V230;Data
Source=sofdb1;Min Pool Size=5;Max Pool Size=100;Connect Timeout=60;"},

{"proxyfactory.factory_class",
"NHibernate.ByteCode.Castle.ProxyFactoryFactory,
NHibernate.ByteCode.Castle"},
}); //
Link para a tabela de Usuarios
return source;
}
}

Mauricio Scheffer

unread,
Mar 8, 2009, 10:22:13 PM3/8/09
to Castle Project Users
It looks like the IsRunningInWebApp setting is overriding the
ThreadScopeInfoImplementation setting (since you explicitly defined
HybridWebThreadScopeInfo but it's still using WebThreadScopeInfo which
is throwing).

Try removing IsRunningInWebApp from your InPlaceConfigurationSource.

On Mar 6, 12:30 pm, Gabriel Mancini de Campos

Gabriel Mancini de Campos

unread,
Mar 9, 2009, 10:42:09 AM3/9/09
to Castle Project Users
Hey Mauricio,

Thanks!
that´s it!, wokrs perfected!

so, there are implications for this ???

Mauricio Scheffer

unread,
Mar 9, 2009, 4:12:11 PM3/9/09
to Castle Project Users
No implications, in this case IsRunningInWebApp is redundant.
However, this is kind of a bug since it's an unexpected behavior... I
think even inverting the order of the properties (first
IsRunningInWebApp, then ThreadScopeInfoImplementation) would have
worked in this case... could you check this? If this is the case
please create an issue (http://support.castleproject.org/projects/AR).

Thanks.

On Mar 9, 12:42 pm, Gabriel Mancini de Campos
Reply all
Reply to author
Forward
0 new messages