Petapoco:操作可能会破坏运行时的稳定性
Petapoco: Operation could destabilize the runtime
我正在尝试使用 Petapoco 的多 poco 查询。
代码在我的本地机器上工作正常 运行 .NET 4.6.1 但在部署到我正在使用的主机时抛出 System.Security.VerificationException 运行.NET 4.5.
的片段
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 的回调,但为了论证,我只是 return 通过的对象:
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
);
有什么线索可以说明为什么会抛出这个异常吗?
我认为这是因为托管环境设置为中等信任。因为PetaPoco在正常运行时会生成IL代码,中等信任的托管环境不会允许,会抛出异常。
我正在尝试使用 Petapoco 的多 poco 查询。
代码在我的本地机器上工作正常 运行 .NET 4.6.1 但在部署到我正在使用的主机时抛出 System.Security.VerificationException 运行.NET 4.5.
的片段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 的回调,但为了论证,我只是 return 通过的对象:
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
);
有什么线索可以说明为什么会抛出这个异常吗?
我认为这是因为托管环境设置为中等信任。因为PetaPoco在正常运行时会生成IL代码,中等信任的托管环境不会允许,会抛出异常。