我正在尝试使用 Steve Sanderson's blog post为了在我的 ASP MVC 3 View 中编辑可变长度列表。该项目构建良好,但是每当呈现局部 View 时,程序就会在 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()
局部 View
@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>
Controller
[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 有关。然而,现在我的薪水已经超过了我的薪水等级,因为我不确定如何调试这样的东西。以下是 WinDbg 在 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
更新
通过在项目的调试器菜单中选择“ native 代码”选项
我现在收到了一条稍微更详细的错误消息:
最后,按照下面的建议切换到 IIS Express,我仍然收到 AccessViolationException。这是我用来启用 IIS 进行调试的设置(在项目属性下)
这是错误信息
调用堆栈:
最佳答案
在我看来,你的工作比你需要的更努力。
首先,将 foreach 替换为 for 循环,将索引元素传递到编辑器模板中。这将建立您的模板上下文。
<fieldset>
<legend>Relationship Codes</legend>
<table id="Experiment">
<thead>
<tr>
<th>Relationship Effective Date</th>
<th>Relationship Dist Code</th>
</tr>
</thead>
<tbody>
@for (var i = 0; i < Model.AgentRelationshipCodes.Count(); i++)
{
@Html.EditorFor(model => model.AgentRelationshipCodes[i])
}
</tbody>
</table>
<br/>
<a href="javascript:void(0)" class ="addCode">Add Another</a>
</fieldset>
然后创建一个名为 AgentRelationshipCodes.cshtml 的编辑器模板(在 Views/Shared/EditorTemplates 中)
@model Monet.Models.AgentRelationshipCodes
<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 () {
$('#fieldset').load('@Url.Action("NewRelationshipCode", "AgentTransmission")',$('#fieldset').closest('form').serialize());
});
});
</script>
<div id="fieldset">
@Html.Partial("fieldset");
</div>
并从您的 NewRelationshipCode 操作方法返回字段集 View :
[HandleProcessCorruptedStateExceptions]
public ViewResult NewRelationshipCode(YourViewModel model)
{
model.AgentRelationshipCodes.Add(new AgentRelationshipCodes());
return View("fieldset", model);
}
关于c# - AccessViolationException 未处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23437760/
Rackup通过Rack的默认处理程序成功运行任何Rack应用程序。例如:classRackAppdefcall(environment)['200',{'Content-Type'=>'text/html'},["Helloworld"]]endendrunRackApp.new但是当最后一行更改为使用Rack的内置CGI处理程序时,rackup给出“NoMethodErrorat/undefinedmethod`call'fornil:NilClass”:Rack::Handler::CGI.runRackApp.newRack的其他内置处理程序也提出了同样的反对意见。例如Rack
如何在ruby中调用C#dll? 最佳答案 我能想到几种可能性:为您的DLL编写(或找人编写)一个COM包装器,如果它还没有,则使用Ruby的WIN32OLE库来调用它;看看RubyCLR,其中一位作者是JohnLam,他继续在Microsoft从事IronRuby方面的工作。(估计不会再维护了,可能不支持.Net2.0以上的版本);正如其他地方已经提到的,看看使用IronRuby,如果这是您的技术选择。有一个主题是here.请注意,最后一篇文章实际上来自JohnLam(看起来像是2009年3月),他似乎很自在地断言RubyCL
我正在尝试在Ruby中复制Convert.ToBase64String()行为。这是我的C#代码:varsha1=newSHA1CryptoServiceProvider();varpasswordBytes=Encoding.UTF8.GetBytes("password");varpasswordHash=sha1.ComputeHash(passwordBytes);returnConvert.ToBase64String(passwordHash);//returns"W6ph5Mm5Pz8GgiULbPgzG37mj9g="当我在Ruby中尝试同样的事情时,我得到了相同sha
C#实现简易绘图工具一.引言实验目的:通过制作窗体应用程序(C#画图软件),熟悉基本的窗体设计过程以及控件设计,事件处理等,熟悉使用C#的winform窗体进行绘图的基本步骤,对于面向对象编程有更加深刻的体会.Tutorial任务设计一个具有基本功能的画图软件**·包括简单的新建文件,保存,重新绘图等功能**·实现一些基本图形的绘制,包括铅笔和基本形状等,学习橡皮工具的创建**·设计一个合理舒适的UI界面**注明:你可能需要先了解一些关于winform窗体应用程序绘图的基本知识,以及关于GDI+类和结构的知识二.实验环境Windows系统下的visualstudio2017C#窗体应用程序三.
我对图像处理完全陌生。我对JPEG内部是什么以及它是如何工作一无所知。我想知道,是否可以在某处找到执行以下简单操作的ruby代码:打开jpeg文件。遍历每个像素并将其颜色设置为fx绿色。将结果写入另一个文件。我对如何使用ruby-vips库实现这一点特别感兴趣https://github.com/ender672/ruby-vips我的目标-学习如何使用ruby-vips执行基本的图像处理操作(Gamma校正、亮度、色调……)任何指向比“helloworld”更复杂的工作示例的链接——比如ruby-vips的github页面上的链接,我们将不胜感激!如果有ruby-
我有一个super简单的脚本,它几乎包含了FayeWebSocketGitHub页面上用于处理关闭连接的内容:ws=Faye::WebSocket::Client.new(url,nil,:headers=>headers)ws.on:opendo|event|p[:open]#sendpingcommand#sendtestcommand#ws.send({command:'test'}.to_json)endws.on:messagedo|event|#hereistheentrypointfordatacomingfromtheserver.pJSON.parse(event.d
我正在尝试解析网页,但有时会收到404错误。这是我用来获取网页的代码:result=Net::HTTP::getURI.parse(URI.escape(url))如何测试result是否为404错误代码? 最佳答案 像这样重写你的代码:uri=URI.parse(url)result=Net::HTTP.start(uri.host,uri.port){|http|http.get(uri.path)}putsresult.codeputsresult.body这将打印状态码和正文。
我查看了Stripedocumentationonerrors,但我仍然无法正确处理/重定向这些错误。基本上无论发生什么,我都希望他们返回到edit操作(通过edit_profile_path)并向他们显示一条消息(无论成功与否)。我在edit操作上有一个表单,它可以POST到update操作。使用有效的信用卡可以正常工作(费用在Stripe仪表板中)。我正在使用Stripe.js。classExtrasController5000,#amountincents:currency=>"usd",:card=>token,:description=>current_user.email)
我如何做Ruby方法"Flatten"RubyMethod在C#中。此方法将锯齿状数组展平为一维数组。例如:s=[1,2,3]#=>[1,2,3]t=[4,5,6,[7,8]]#=>[4,5,6,[7,8]]a=[s,t,9,10]#=>[[1,2,3],[4,5,6,[7,8]],9,10]a.flatten#=>[1,2,3,4,5,6,7,8,9,10 最佳答案 递归解决方案:IEnumerableFlatten(IEnumerablearray){foreach(variteminarray){if(itemisIEnume
当profile为nil时,总是让我感到悲伤...我该怎么办? 最佳答案 在View中使用变量之前,始终检查变量是否为nil。我确信这个问题有更优雅的解决方案,但这应该能让您入门。 关于ruby-on-rails-Rails处理.Erb与Nils,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/2709605/