locked
Debugging doesn't show any error in Error List Windows?

    Question

  • Lately when I start debugging in VS2011, if there is any error, it won't show any error message in Error List windows(for example, when I assignd a value to the variable that was not declared, rather than show some message like '*** is undefined', nothing appears in Error List).


    When I just installed Windows Develop Preview, everything worked fine and error detection still could worked normally. At this time I don't know why this happen(I'm not sure whether I accidentally press something in VS2011). But please help me solve this problem.

    Thanks
    Thursday, March 01, 2012 7:49 AM

Answers

  • The code that you are showing looks to be older code. Are you using the beta version of Visual Studio?

    That said, it is possible that the syntax error you introduced is raising the runtime exception (under strict mode), but that is within a promise that is hiding the exception and therefore the dialog (you should see the syntax error in the output window). As Andy stated above, in the beta you can try setting the Debug>Exceptions>JavaScript Runtime Exceptions>Thrown check box to see if the dialog appears in all cases for you

    Tuesday, March 06, 2012 11:27 PM

All replies

  • Which VS profile (General, VB, C#, etc.) are you using? When you build, do the errors appear in the Output Window AND the Error List? Which project type are you working on (JS, C#, VB, etc.)?
    • Proposed as answer by nobu7426Banned Tuesday, January 29, 2013 5:03 PM
    • Unproposed as answer by nobu7426Banned Tuesday, January 29, 2013 5:03 PM
    • Proposed as answer by nobu7426Banned Tuesday, January 29, 2013 5:04 PM
    Thursday, March 01, 2012 6:42 PM
  • I'm working on HTML5/Javascript at this time. But I believe I used to see some error message showing in Error List. But at this time, nothing appears on Output Window and Error List.

    Furthermore, I remember that I used to see some strange thing happened. At the time when my Error Detection still worked fine, I made some error in Javascript code by assigning some value to the variable which I forgot to declared. Then I fixed it. Everything worked fine but there was still error message in Error List that 'my variable is undefined'. I closed Error List window then re-open it. Then, I think that was the last time I saw an error message on Error List.

    By the way, how can I know my VS profile?

    • Proposed as answer by nobu7426Banned Tuesday, January 29, 2013 5:05 PM
    Friday, March 02, 2012 1:53 AM
  • For JavaScript projects, errors will only show in the Error List if the file is open in the editor.  This is true even during deployment (e.g. F5).  If the file is included in your project, but closed, no syntax errors will be detected in it.  However, only syntax errors will show in the error list during design time.  Other runtime errors, such as your case of assigning to a variable that was undeclared, will show up in the output window during debugging as a runtime error (e.g. 0x800a13b2 - JavaScript runtime error: Variable undefined in strict mode).

    Regarding how to know which profile is selected, it would be whatever you selected the first time you started Visual Studio.  If you are using Visual Studio Express, then there is only a single Metro profile.  If you are using Pro/Ultimate, if you don't recall and want to be reminded, you can check the registry at HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0\Profile (LastResetSettingsFile).

    Friday, March 02, 2012 2:09 AM
  • In addition to the output window JavaScript errors will also appear in the JavaScript console (Debug|Windows|JavaScript Console). You should also get a dialog box reporting the runtime exception. If the exception was handled you will need to enable thrown exceptions to in the Debug|Exceptions dialog and the debugger will always pop the dialog and break on all runtime exceptions.
    Friday, March 02, 2012 2:23 AM
  • About the popup window that might appear to throw the exception (the one that contains 3 button 'Ignore', 'Break', 'Continue' showing with the error details).I remembered that I always see this popup when my javascript contains syntax error. So I just tested by putting some error like undeclared variable then putting 2 breakpoints in the line which has an error and then the next line which code should works fine.

    Actually after I hit F5 at the first breakpoint in the line of code that has an error, there should be some popup dialog show whether I want to ignore,break or continue right? But no dialog appears and my app continues running without hitting the second breakpoint.

    How could this happen?
    Friday, March 02, 2012 2:49 AM
  • Do you have a code sample you could share?

    Friday, March 02, 2012 3:17 AM
  • I just only new a project, putting some syntax error, then run it.

    For my just-testing-to-see-an-error project, I used Grid Application Template of HTML5/Javascript. Then I put some syntax error like "aaa = 'aaa';" in some function in landingPage.js then start debugging(landingPage.js file is still opened). But no any popup or error message appeared.

    Friday, March 02, 2012 3:22 AM
  • aaa = 'aaa'; 

    Is valid JavaScript it will assign the value of 'aaa' to window.aaa. In a lexical scope with strict mode enabled ("use strict") it's a runtime error and should pop the runtime error dialog.
    Friday, March 02, 2012 3:51 AM
  • Ok Andy,

    From your reply, I decided to try creating another project with the Blank Application Template. Next I added a  a button and add event "click" to it by addEventListener(). Inside event function, i put "aaa = 'aaa';" then run program. When I clicked button, At this time popup that show an syntax error has appeared!?

    Then is it related to strict mode or not? How come an error pop-up appears when I just add some error in event, but nothing was shown when I just put some error in default-template function like getItem() in Grid Application Template?

    Friday, March 02, 2012 4:05 AM
  • You would need to paste the code you're using as it's hard to tell if "use strict" is in the scope of your aaa='aaa'. It's likely it is strict mode but I can't find a function named getItem in the default grid template.
    Friday, March 02, 2012 4:29 AM
  • Here is the code, Andy

    (function () {
        'use strict';
    
        var listRenderer;
        var headerRenderer;
        var itemRenderer;
        var pageLayout;
    
        // Custom event raised after the fragment is appended to the DOM.
        WinJS.Application.addEventListener('fragmentappended', function handler(e) {
            if (e.location === '/html/landingPage.html') { fragmentLoad(e.fragment, e.state); }
        });
    
        function updateForLayout(lv, layout) {
            pageLayout = layout;
            if (pageLayout === Windows.UI.ViewManagement.ApplicationLayoutState.snapped) {
                WinJS.UI.setOptions(lv, {
                    dataSource: pageData.groups,
                    itemRenderer: listRenderer,
                    groupDataSource: null,
                    groupRenderer: null,
                    oniteminvoked: itemInvoked
                });
    
                lv.layout = new WinJS.UI.ListLayout();
            } else {
                var groupDataSource = new WinJS.UI.GroupDataSource(
                        new WinJS.UI.ListDataSource(pageData.groups), function (item) {
                            return {
                                key: item.data.group.key,
                                data: {
                                    title: item.data.group.title,
                                    click: function () {
                                        WinJS.Navigation.navigate('/html/collectionPage.html', { group: item.data.group });
                                    }
                                }
                            };
                        });
    
                WinJS.UI.setOptions(lv, {
                    dataSource: pageData.items,
                    itemRenderer: itemRenderer,
                    groupDataSource: groupDataSource,
                    groupRenderer: headerRenderer,
                    oniteminvoked: itemInvoked
                });
                lv.layout = new WinJS.UI.GridLayout({ groupHeaderPosition: 'top' });
            }
            lv.refresh();
        }
    
        function layoutChanged(e) {
            var list = document.querySelector('.landingList');
            if (list) {
                var lv = WinJS.UI.getControl(list);
                updateForLayout(lv, e.layout);
            }
        }
    
        function fragmentLoad(elements, options) {
            try {
                var appLayout = Windows.UI.ViewManagement.ApplicationLayout.getForCurrentView();
                if (appLayout) {
                    appLayout.addEventListener('layoutchanged', layoutChanged);
                }
            } catch (e) { }
    
            WinJS.UI.processAll(elements)
                .then(function () {
                    itemRenderer = elements.querySelector('.itemTemplate');
                    headerRenderer = elements.querySelector('.headerTemplate');
                    listRenderer = elements.querySelector('.listTemplate');
                    var lv = WinJS.UI.getControl(elements.querySelector('.landingList'));
                    updateForLayout(lv, Windows.UI.ViewManagement.ApplicationLayout.value);
                });
        }
    
        function itemInvoked(e) {
            if (pageLayout === Windows.UI.ViewManagement.ApplicationLayoutState.snapped) {
                var group = pageData.groups[e.detail.itemIndex];
                WinJS.Navigation.navigate('/html/collectionPage.html', { group: group });
            } else {
                var item = pageData.items[e.detail.itemIndex];
                WinJS.Navigation.navigate('/html/detailPage.html', { item: item });
            }
        }
    
        // The getGroups() and getItems() functions contain sample data.
        // TODO: Replace with custom data.
        function getGroups() {
            var colors = ['rgba(209, 211, 212, 1)', 'rgba(147, 149, 152, 1)', 'rgba(65, 64, 66, 1)'];
            var groups = [];
    
            for (var i = 0; i < 6; i++) {
                var even = (i % 2) === 0;
                groups.push({
                    key: 'group' + i,
                    title: 'Collection title lorem ' + i,
                    backgroundColor: colors[i % colors.length],
                    label: 'Eleifend posuere',
                    description: even ? 'ǺSed nisl nibh, eleifend posuere.' : 'ǺSed nisl nibh, eleifend posuere laoreet egestas, porttitor quis lorem.',
                    fullDescription: 'Ǻ Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.' + (even ? '' : ' Ǻ Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.')
                });
            }
    
            return groups;
        }
    
        function getItems() {
            var colors = ['rgba(209, 211, 212, 1)', 'rgba(147, 149, 152, 1)', 'rgba(65, 64, 66, 1)'];
            var items = [];
    
            aaa = 'aaa';
    
            for (var g = 0, gl = pageData.groups.length; g < gl; g++) {
                var numItems = g % 2 === 0 ? 6 : 4;
                for (var i = 0; i < numItems; i++) {
                    items.push({
                        group: pageData.groups[g],
                        key: 'item' + i,
                        title: g + '.' + i + (i % 2 === 0 ? ' ǺSed nisl nibh, eleifend posuere.' : ' ǺSed nisl nibh, eleifend posuere laoreet egestas, porttitor quis lorem.'),
                        subtitle: 'Phasellus faucibus',
                        backgroundColor: colors[i % colors.length],
                        content: (new Array(16)).join('<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.</p>'),
                        description: 'Ǻ Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.'
                    });
                }
            }
    
            return items;
        }
    
        var pageData = {};
        pageData.groups = getGroups();
        pageData.items = getItems();
    
        WinJS.Namespace.define('landingPage', {
            fragmentLoad: fragmentLoad,
            itemInvoked: itemInvoked
        });
    })();
    

    Sorry about the function name, it is 'getItems' not 'getItem'. This is from landingPage.js, and note that I already put = "aaa = 'aaa';"

    Friday, March 02, 2012 4:38 AM
  • The code that you are showing looks to be older code. Are you using the beta version of Visual Studio?

    That said, it is possible that the syntax error you introduced is raising the runtime exception (under strict mode), but that is within a promise that is hiding the exception and therefore the dialog (you should see the syntax error in the output window). As Andy stated above, in the beta you can try setting the Debug>Exceptions>JavaScript Runtime Exceptions>Thrown check box to see if the dialog appears in all cases for you

    Tuesday, March 06, 2012 11:27 PM
  • Thanks Simon, I used the VS 2011 Express that comes with Windows Developer Preview 64-Bit. I haven't try the new version yet. Then again, I will try your settings solution later.
    Thursday, March 08, 2012 8:28 AM