Petapoco:操作可能破坏运行时的稳定性

我正在尝试使用Petapoco的多poco查询。

代码在运行.NET 4.6.1的本地计算机上正常工作,但在部署到我正在使用的运行.NET 4.5的主机时抛出System.Security.VerificationException

来自PetaPoco / Database.cs的Snipppet: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的回调,但是为了参数的缘故,我只是返回通过的对象:

 public Person MapRow(Person person, Category category, Country country) { return person; } 

我正在调用这样的方法:

 db.Query( new[] { typeof(Person), typeof(Category), typeof(Country) }, new PersonRelator().MapRow, sql ); 

为什么抛出这个exception的任何线索?

我认为这是因为托管环境设置为中等信任。 由于PetaPoco在正常操作期间生成IL代码,因此中等信任托管环境将不允许它并将引发exception。