在对控制器中的AddTagsCollection
动作行为进行故障排除时,我有一个奇怪的场景,我之前没有遇到过,它甚至不是多线程部分。 Visual Studio调试器进入函数直到第一行string alert = "";
,甚至在调试器处停止,但从不进入其他行!!
public JsonResult AddTagsCollection(int collectionID, string Name, string Description, string Order, bool IsActive, bool RootUseOnly)
{
// Yes hits this break point only then bails out - whats going on??
string Alert = "";
// NEVER hits this break point
if (ProfileTagCollection.GetByName(Name.Trim()).ProfileTagCollectionID > 0)
Alert = "The collection \"" + Name + "\" already exists.";
// NEVER hits this break point!!!
var testme = "test";
// NEVER hits this break point - you get the idea, it just return back to the HTML view??
if (Name.Trim().ToLower().Length == 0)
Alert = "The collection name should not be empty.";
if (Alert != "")
{
RequestResultModel _model = new RequestResultModel();
_model.InfoType = RequestResultInfoType.ErrorOrDanger;
_model.Alert = Alert;
AuditEvent.AppEventWarning(Profile.Member.Email, Alert);
return Json(new
{
NotifyType = NotifyType.DialogInline,
Html = this.RenderPartialView(@"_RequestResultDialogInLine", _model),
}, JsonRequestBehavior.AllowGet);
}
ProfileProfileTagCollection ProfileTagCollection = new ProfileProfileTagCollection();
tagCollection.OrderID = 0;
tagCollection.tagCollectionName = Name;
tagCollection.tagCollectionDescription = Description;
tagCollection.IsActive = IsActive ? 1 : 0;
tagCollection.RootUseOnly = RootUseOnly ? 1 : 0;
tagCollection.Save();
if (collectionID > 0)
AuditEvent.AppEventSuccess(Profile.Member.Email, String.Format("The \"{0}\" profile collection has been updated.", Name));
else
AuditEvent.AppEventSuccess(Profile.Member.Email, String.Format("The \"{0}\" profile collection has been added.",Name));
if (Order != "")
{
Order = Order.Replace("this", tagCollection.tagCollectionID.ToString());
ProfiletagCollections.UpdateOrder(Order);
}
// I have tried passing other combinations to reach here, but why does it not get here
return Json(new {
NotifyType = -1,
Html = "",
}, JsonRequestBehavior.AllowGet);
}
我还尝试查找调试窗口模块,在2013年未列出,已移动...在调试模式下,选择debug-&gt; windows-&gt;模块(模块遗失给我)< / em>的
你能帮助我解决为什么调试器没有达到断点以及我可以采取哪些步骤来解决或调查这个问题?
答案 0 :(得分:0)
我认为你可以使用this
你可能正在追求这样的事情:
如果(System.Diagnostics.Debugger.IsAttached)
System.Diagnostics.Debugger.Break();当然,这仍然会得到 在发布版本中编译。如果你想让它表现得更像 调试对象,代码在Release版本中根本不存在, 然后你可以做这样的事情:[有条件的(&#34; DEBUG&#34;)] void DebugBreak(){
如果(System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debugger.Break();然后在代码中添加对它的调用。