Tip for debugging JavaScript metro apps

April 5, 2012 at 7:52 am | Posted in HTML/JavaScript, Metro, Visual Studio, Windows 8 | Leave a comment

With the release of the Windows 8 beta, I’ve been playing around again with metro apps made with HTML/JavaScript.  I was frustrated with debugging situations in which portions of code just didn’t seem to execute while displaying no error messages.  Then yesterday, I discovered this.  It explains that code with Promises deals with runtime errors in a special way and expects error handling routines to react to appropriately.

It is helpful to make sure that the Visual Studio menu item Debug > Exceptions > JavaScript Runtime > Thrown is selected.  This should expose errors that the runtime has detected but is ‘holding’ for some handling routine that is often not yet implemented.


Cider Tricks: Menus, TabPages, ToolBars

November 30, 2007 at 11:21 am | Posted in C#, Cider, Visual Studio, WPF | 1 Comment

The frustrating thing about the WPF Designer in VS2008 (a.k.a. “Cider”) is that it does not support drag and drop placement of items for every control. The first three that I encountered were menus, toolbars and laying out controls on a tab page. The IDE does have some capability to facilitate the design of these items that don’t require exclusive XAML coding. You just have to know the techniques to use them.


While you can add MenuItem to the toolbox, you can not drag it to the content portion of a Menu control in the designer. The easy way to create Menus is as follows:

1. Drag a Menu control from the toolbox onto the window.

2. Select the Menu control and find the Items property in the Property window. Click on the (…) icon. This will bring up the Collection Editor dialog.

3. Use it to add MenuItems. You can edit the properties of each item (like the Header property) as well as add sub-items by clicking on the Items property of the MenuItem. For the sub-items, you can also add a separator.


Items in a ToolBar can only be added with the XAML editor. Once added, you can edit and move them using the Collection Editor for the ToolBar.


You cannot layout controls directly on a TabItem for a TabControl. There are two tricks that are required: use a Grid panel and using the SelectedIndex to put each page in view for layout.

1. Drag a TabControl from the toolbox onto the window.

2. Using the Items propery in the Property window, add your TabItems and enter the Header properties for each one.

3. In the XAML editor, add a Grid to each TabItem like this:


4. Select the TabControl and locate the SelectedIndex property. Change the index to the page you want to layout.

5. Drag and drop items from the toolbox onto the Grid of the TabItem.

Visual Studio 411

August 16, 2007 at 9:14 am | Posted in .Net, C#, Visual Studio | Leave a comment

Visual Studio has a powerful array of features that can greatly boost productivity–especially for new programmers who may not have a full grasp of the .Net framework.  While the C# language itself is quite compact and comprehensible, the number of classes available in the .Net framework is almost mind boggling.  How is a newcomer supposed to remember it all?

The good news is that with Visual Studio you don’t have to.  You just need to know how to get the information (‘411’) when you need it.  Here are the most helpful features for me:


There are three big productivity enhancements that I get out of Intellesense.  First, I use it to help find out what is possible with an object.  By typing a ‘.’ after the object name in a statement, the Intellesense drop down shows all of the properties and methods that are available to me.  Icons by the names of the members indicate the type (properties: a page with a hand, methods: a diamond, events: a lightning bolt).  Second, selecting one of the members gives a brief synopsis which includes the type of value returned and the arguments that are expected.  After selecting, if I type another delimiter (a space, a dot, a parenthesis), Intellesense will  enter the code for me reducing the possibility of making a typographical mistake.  For methods, entering the open parenthesis results in Intellesense showing the possible overloads (different argument possibilities).  Intellesense is almost like having an expert programmer sitting over your shoulder advising you every step of the way.

Dynamic Help

Dynamic help is a way of quickly getting to more information from the MSDN documentation file.  Turn this feature on using menu Help > Dynamic Help.  Now, when you click on an item in the code view or the designer view, a list of links to the Help documentation is presented.  Click on a link and most likely you will get exactly the information you are seeking.

MSDN Documentation

Newcomers need to understand the format of the help documentation so as not to be overwhelmed by its scope.  Every class typically has the following organization: an overview page, a members page listing all properties, methods and events, finally leading to pages for individual members.  More often than not, the individual members page will offer an example that can be adapted or even copied directly into the application.


For me, the most useful way of getting to the information in the documentation (outside of dynamic help) is to use the Index: menu Help > Index.  Also available are ‘Search’ and ‘Content’ but ‘Index’ works best for me.

How do I

Help > How do I can also lead to helpful articles in the documentation for doing the most common tasks like File IO or drawing.

Getting Help Online

Outside of Visual Studio there is a wealth of information.  If I have a question about a control or how to do something, chances are good that someone else has had the same problem and has already posted the solution.  I usually fire up a search engine and put in a few keywords about the problem along with ‘msdn’.  This biases the search to either the msdn documentation or one of the msdn forums.

For me, asking a question in an online forum is my option of last resort.  Not that it is a bad thing to do but the time I spend using the other resources available is always a valuable learning experience in itself and can turn up nuggets that can be used in later projects.

Renaming things in Visual Studio

August 14, 2007 at 7:03 am | Posted in Visual Studio | 9 Comments

Many newcomers to Visual Studio experience the problem of breaking their application after renaming something.  I certainly have!  First, there are many different names that are used to tag different things (see list below); second, there are multiple ways of renaming things and the impact on the IDE are not always clear to the novice; third, renaming things can sometimes confuse the Designer and your program because of references to names in the Designer generated code and helper files.

Here are some general guidelines that work for me:

1. It is always easier to name things when you first add them to your project. This includes everything from the initial project name to the controls you drag to your form from the toolbox.

2. Before renaming things like Classes, UserControls, NameSpaces, Assemblies etc, back up your project. This can be easily done in the Windows Explorer by making a copy of the Solution Folder for the project (found in your VS Projects Folder).

3. To change the name of something in your user code such as NameSpace, Class or UserControl, select an instance of the name in your code editor and use the Refactor > Rename function. You may have to rebuild the solution after this to get things back to normal.

4. To change the name of the Solution File or Project File, use the Solution Explorer and right click > Rename.

Here is a list of various high-level names that one might want to manage:

Solution Folder – this is the name of the top folder in the ..\Visual Studio 2005\Projects Folder. Change in Windows Explorer. Note that it is possible that this will confuse the Recent Projects Start Page but you should be able to use Open …Projects to find it.

Project Folder – this is the name of the folder(s) inside the Solution Folder with project data. (A solution can have more than one project.) Change in Windows Explorer. Note that it is possible that this will confuse the Recent Projects Start Page but you should be able to use Open …Projects to find it.

Solution File – the name of the solution. Change in the Solution Explorer, right-click Rename. Note that it is possible that this will confuse the Recent Projects Start Page but you should be able to use Open …Projects to find it.

Project File – the name of the project. Change in the Solution Explorer, right-click Rename. Note that it is possible that this will confuse the Recent Projects Start Page but you should be able to use Open …Projects to find it.

Assembly Name – as found in Properties > Application. This will be the name of your .exe file. Change in the Properties >Application dialog.

NameSpace – also in Properties >Application and in your code. This is useful for keeping your class and control names distinct from other code bases. Change using the Refactor.

Title – as found in Properties>Application>Assembly Information. This will be put in the title bar of the AboutBox. Change in the Assembly Information Dialog.

Product – also as found in Properties>Application>Assembly Information. This will be a name listed in the AboutBox. Change in the Assembly Information Dialog.

Testing the Visual Studio Plug-in

August 12, 2007 at 7:33 pm | Posted in Visual Studio | Leave a comment

Here is a  code snippet from Visual Studio using the plug-in for Windows Live Writer.

        private void button1_Click(object sender, EventArgs e)
            string[] names = { "Scott", "George", "Mike" };

            Database1DataSet.Table1Row row;

            foreach (string name in names)
                row = database1DataSet.Table1.NewTable1Row();
                row["name"] = name;

It works!!!

public void Page_Loaded(object o, EventArgs e)
    // Required to initialize variables
    //Register the scriptable endpoints
    WebApplication.Current.RegisterScriptableObject("basic", this);

Create a free website or blog at WordPress.com.
Entries and comments feeds.