System.AccessViolationException未知模块
目前,我有我的WebAPI控制器是在我的数据库返回的某些项目的列表:System.AccessViolationException未知模块
如下:
public ICollection<TherapyGroup> OffUnit()
{
return _context.TherapyGroups.OrderBy(g => g.Name)
.Where(x => x.GroupTypeOffUnitOnUnit == TherapyGroup.OffUnit)
.ToList();
}
一切正常,当我对测试精我的本地数据库;但是,当我切换出远程数据库的数据库字符串时,它会引发System.AccessViolationException。基于断点,数据从数据库中正常返回,并且当方法返回到MVC中的WebApi时,问题似乎就出现了。这已经成为一个非常令人沮丧的问题,我很乐意帮助他们进行导航。
装饰你想与HandleProcessCorruptedStateExceptions属性来捕获这些异常的方法。详情请参阅https://msdn.microsoft.com/en-us/magazine/dd419661.aspx#id0070035。
[HandleProcessCorruptedStateExceptions]
[SecurityCritical]
public ICollection<TherapyGroup> OffUnit()
{
try
{
return _context.TherapyGroups.OrderBy(g => g.Name).Where(x => x.GroupTypeOffUnitOnUnit == TherapyGroup.OffUnit).ToList();
}
catch (Exception e)
{
// set break point to see the stack trace.
Debug.WriteLine(e.InnnerException);
return null;
}
}
我已经做到了。它似乎没有达到突破点。这表明问题在返回后发生。 –
@CodyShort,你可以在配置文件中添加'
我认为我越来越问题..我相信在SQL Server V10(远程)和V9(本地)数据类型的方式是不同的某种方式(也许日期时间?)似乎如果我把对象,并使用字符串来准备一个返回对象的东西正在工作。 –
您能否提供您所看到的异常的堆栈跟踪? –
我没有看到堆栈跟踪...请注意,违规发生在未知模块中。 –
请在代码中添加try catch块。然后放置更多细节。 – Bigeyes