标签:style http color strong os art
AR設定檔要指定threadinfotype,不指定的話,預設值是用WebThreadScopeInfo,是用 HttpContext.Current.Items 來存放 SesionScope,所以碰到與UI無關的執行緒,沒有 HttpContext.Current 程式就掛啦。
解决方案一:
1、检查“web.config”
<activeRecord isWeb="true" isDebug="false">
<config>
... ...
</config>
</activeRecord>
2、ActiveRecord加载配置代码修改为:
var source = ConfigurationManager.GetSection("activerecord") as InPlaceConfigurationSource;
source.ThreadScopeInfoImplementation = typeof(Castle.ActiveRecord.Framework.Scopes.HybridWebThreadScopeInfo);
ActiveRecordStarter.Initialize(assemblies, source);
解决方案二:
1、修改web.config,注意蓝色部分:
<activerecord isWeb="true" isDebug="true" threadinfotype="Castle.ActiveRecord.Framework.Scopes.HybridWebThreadScopeInfo,
Castle.ActiveRecord">
<config>
... ...
</config>
</activerecord>
解决方案三:
1、在web.config中加入:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
[掌眼]解决Castle.ActiveRecord在ASP.NET或WCF环境中HttpContext.Current无效的错误,布布扣,bubuko.com
[掌眼]解决Castle.ActiveRecord在ASP.NET或WCF环境中HttpContext.Current无效的错误
标签:style http color strong os art
原文地址:http://www.cnblogs.com/yipu/p/3834921.html