0

In troubleshooting AddTagsCollection Action behavior in a controller, I have a strange scenario which I have not encountered before, its not even a multi threaded section. The Visual Studio Debugger enters the function till the first line string alert = ""; and even stops at the debugger but never goes on to the other lines!!

 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);

    }

I also tried to lookup the debug windows module, in 2013 its not listed, has it moved... In debug mode, select debug->windows->modules (modules is missing for me)

Can you help me with why the debugger does not hit the break point and what steps I can take to resolve or investigate this?

Crew
  • 37
  • 1
  • 9

1 Answers1

0

I think you could use this

You probably are after something like this:

if(System.Diagnostics.Debugger.IsAttached)
System.Diagnostics.Debugger.Break(); Of course that will still get compiled in a Release build. If you want it to behave more like the Debug object where the code simply doesn't exist in a Release build, then you could do something like this:

[Conditional("DEBUG")] void DebugBreak() {
if(System.Diagnostics.Debugger.IsAttached) System.Diagnostics.Debugger.Break(); } Then add a call to it in your code.

Community
  • 1
  • 1
Thealon
  • 1,935
  • 1
  • 13
  • 22