Petapoco:操作可能会破坏运行时间 [英] Petapoco: Operation could destabilize the runtime
问题描述
我正在尝试使用Petapoco的多poco查询.
I am trying to use Petapoco's multi-poco query.
代码在运行.NET 4.6.1的本地计算机上运行良好,但是在部署到我正在使用的运行.NET 4.5的主机时,抛出 System.Security.VerificationException .
The code works fine on my local machine running .NET 4.6.1 but throws System.Security.VerificationException when deployed to the hosting I am using which is running .NET 4.5.
来自
Snipppet from PetaPoco/Database.cs:2253
while (true)
{
TRet poco;
try
{
if (!r.Read())
break;
poco = factory(r, cb); // <-- The exception happens here
}
catch (Exception x)
{
if (OnException(x))
throw;
yield break;
}
if (poco != null)
yield return poco;
else
bNeedTerminator = true;
}
"cb"是映射pocos的回调,但是出于参数的考虑,我只返回了遇到的对象:
"cb" is the callback to map the pocos, but for the sake of the argument I made it just return the object that came through:
public Person MapRow(Person person, Category category, Country country) {
return person;
}
我正在这样调用方法:
db.Query<Person>(
new[] { typeof(Person), typeof(Category), typeof(Country) },
new PersonRelator().MapRow,
sql
);
任何线索为何会引发此异常?
Any clues why this exception is being thrown?
推荐答案
我认为这是因为托管环境设置为中等信任.由于PetaPoco在正常操作期间会生成IL代码,因此中等信任托管环境将不允许它,并将引发异常.
I think this is because the hosting environment is set to medium trust. Because PetaPoco generates IL code during normal operations, medium trust hosting environment will not allow it and will throw an exception.
这篇关于Petapoco:操作可能会破坏运行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!