我正在尝试使用Steve Sanderson 的博客文章在我的 ASP MVC 3 视图中编辑可变长度列表。该项目构建良好,但是每当呈现部分视图时,程序就会因using(Html.BeginColletionItem()
以下错误而爆炸:
AccessViolationException was unhandled
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
这是完整异常的屏幕截图
下面的完整堆栈跟踪
at Microsoft.VisualStudio.WebHost.Host.ProcessRequest(Connection conn)
at Microsoft.VisualStudio.WebHost.Server.OnSocketAccept(Object acceptedSocket)
at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
局部视图
@model Monet.Models.AgentRelationshipCodes
@using (Html.BeginCollectionItem("AgentRelationshipCodes")) @*Exception thrown here*@
{
<tr>
<td>@Html.EditorFor(model => model.EffectiveDate, "NullableDate", new { @class = "relCodeDate2" })</td>
<td>@Html.EditorFor(model => model.RelationshipId, "NullableDate", new { @class = "relDistCode1", maxlength = 3 })</td>
@Html.HiddenFor(model => model.ID)
@Html.HiddenFor(model => model.RelCodeOrdinal)
</tr>
}
看法
<script>
$(document).ready(function() {
$(".addCode").click(function () {
$.ajax({
url: '@Url.Action("NewRelationshipCode", "AgentTransmission")',
dataType: 'html',
cache: false,
success: function (html) {
console.log(html);
$("#Experiment > tbody").append(html);
}
})
});
});
</script>
.
.
<fieldset>
<legend>Relationship Codes</legend>
<table id="Experiment">
<thead>
<tr>
<th>Relationship Effective Date</th>
<th>Relationship Dist Code</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.AgentRelationshipCodes)
{
@Html.Partial("AddRelationshipCodePartial", item)
}
</tbody>
</table>
<br/>
<a href="javascript:void(0)" class ="addCode">Add Another</a>
</fieldset>
控制器
[HandleProcessCorruptedStateExceptions]
public ViewResult NewRelationshipCode()
{
return View("AddRelationshipCodePartial", new AgentRelationshipCodes());
}
代理关系代码
namespace Monet.Models
{
using System;
using System.Collections.Generic;
public partial class AgentRelationshipCodes
{
public int ID { get; set; }
public int RelCodeOrdinal { get; set; }
public string RelationshipId { get; set; }
public Nullable<System.DateTime> EffectiveDate { get; set; }
public System.DateTime LastChangeDate { get; set; }
public string LastChangeId { get; set; }
public virtual AgentTransmission AgentTransmission { get; set; }
}
}
编辑
我已经能够让演示在我现在使用的解决方案之外的项目中工作,所以它显然与这个工作区中的一些 dll 有关。但是,现在我已经超出了我的工资等级,因为我不确定如何调试这样的东西。以下是在 Visual Studio 抛出AccessViolationException
. 在抛出的异常之间有很多信息,如果有人需要,请告诉我。
*** WARNING: Unable to verify checksum for C:\Windows\assembly\NativeImages_v4.0.30319_32\mscorlib\d12f4fda3d1bfabf888342e96983e9a7\mscorlib.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for C:\Windows\assembly\NativeImages_v4.0.30319_32\mscorlib\d12f4fda3d1bfabf888342e96983e9a7\mscorlib.ni.dll
*** WARNING: Unable to verify checksum for C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Xaml\9d3572e8c3c314a0f12383d41e8bee78\System.Xaml.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for C:\Windows\assembly\NativeImages_v4.0.30319_32\System.Xaml\9d3572e8c3c314a0f12383d41e8bee78\System.Xaml.ni.dll
*** WARNING: Unable to verify checksum for C:\Windows\assembly\NativeImages_v4.0.30319_32\Presentatio5ae0f00f#\8711b01d60a94d6ef6a02d7fd0578493\PresentationFramework.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for C:\Windows\assembly\NativeImages_v4.0.30319_32\Presentatio5ae0f00f#\8711b01d60a94d6ef6a02d7fd0578493\PresentationFramework.ni.dll
*** WARNING: Unable to verify checksum for C:\Windows\assembly\NativeImages_v4.0.30319_32\WindowsBase\ac2e26bafa70e93b307087d7fe6b9dd2\WindowsBase.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for C:\Windows\assembly\NativeImages_v4.0.30319_32\WindowsBase\ac2e26bafa70e93b307087d7fe6b9dd2\WindowsBase.ni.dll
*** WARNING: Unable to verify checksum for C:\Windows\assembly\NativeImages_v4.0.30319_32\Microsoft.V4e91a071#\207156ac71b58fb31310a2f78c3d0c44\Microsoft.VisualStudio.Web.Application.ni.dll
*** ERROR: Module load completed but symbols could not be loaded for C:\Windows\assembly\NativeImages_v4.0.30319_32\Microsoft.V4e91a071#\207156ac71b58fb31310a2f78c3d0c44\Microsoft.VisualStudio.Web.Application.ni.dll
更新
通过在项目的调试器菜单中选择“本机代码”选项
我现在收到一条更详细的错误消息:
最后,按照下面的建议切换到 IIS Express,我仍然收到AccessViolationException
. 这是我用来启用 IIS 进行调试的设置(在项目属性下)
这是错误消息
调用堆栈: