Visual Studio 11 and Windows 8

The trade press is beginning to talk about Visual Studio 11 quite a bit more often now, even though the release of the initial beta won’t even happen today (coincident with the consumer release of Windows 8). The word on the streets is that you won’t see anything too exciting or unexpected in Visual Studio 11. Yes, Microsoft is making the usual laundry list of changes, but there isn’t anything that you wouldn’t expect them to add. Here’s a quick overview of the changes that I’ve been able to glean from the various articles I’ve read:

 

  • HTML5 and JavaScript support
  • Touch application support
  • Agile application development
  • Cloud application development
  • .NET Framework 4.5 support
  • Metro interface designers
  • Devops integration (a tool designed to make it easier for administrators and developers to communicate)
  • IntelliTrace updates that make it possible to trace activity in operational applications
  • Asynchronous programming updates
  • Parallel program development
  • Improved SharePoint support


In other words, Visual Studio 11 is targeting Windows 8 and Windows Azure development. Along with these changes, there are rumors that Microsoft will simplify the IDE to make it easier to use. I just hope that they don’t bury functionality in places where you can’t find it. The Ribbon interface that Microsoft is so fond of adding to other applications does just that—making them a nightmare for power users to use, while simultaneously reducing the learning curve for the novice (the bad and the good that comes with any change).

There isn’t any mention of one of my pet peeves with Visual Studio 10, it’s voracious appetite for system resources and an unflinching desire to freeze the system. The current version of Visual Studio tends to require me to reboot my system at least once during any programming session.

Also missing from the laundry list is any mention of Silverlight, which makes me wonder whether Microsoft is putting this technology out to pasture. In addition, there was nary a mention anywhere of updated Windows Phone support. You’d think that Microsoft would be providing some updated support for Windows Phone development considering that many developers will need to support the mobile device. More and more users are augmenting their desktop systems (or replacing them entirely) with mobile devices, so Microsoft had better get on the ball.

Everything I’m reading focuses on Microsoft’s two main languages C# and Visual Basic. For example, I haven’t seen anything about F#, which appears in the current product. Of course, IronPython was orphaned quite some time ago, but the IronPython community remains alive and well (see my IronPython 2.7.1 Update post for details). This lack of information makes me wonder about the future of Microsoft’s other languages (including C++).

Of course, the updates in Visual Studio 11 and the .NET Framework 4.5 will affect applications of all sorts. During the upcoming months I’ll try to test all of the application examples in my books to determine whether there are any issues you need to know about. In the meantime, please continue to use the supported versions of Visual Studio when working through the examples in my books to ensure you have the best learning experience possible. Contact me with any concerns or observations you have about Visual Studio 11 at John@JohnMuellerBooks.com.

 

IronPython 2.7.1 Update

There are times where it’s hard for me to keep up with every software update out there, much as it’s hard for you. IronPython was a somewhat different product when I originally wrote Professional IronPython. One of the best changes has been the addition of support in Visual Studio for a variety of project types. You still can’t use designers to create your interface effectively, but things are moving in the right direction. I had downloaded the 2.7.1 version of IronPython nearly as soon as it became available, but a number of personal projects and other requirements got in the way of my testing it with the source code in Professional IronPython. The testing is finished and I haven’t encountered any major problems with the update. If someone does encounter a problem, let me know at John@JohnMuellerBooks.com.

The update does include the usual bug fixes. You’ll want to peruse this list to see if the bug you reported has been fixed. As far as I was able to tell, none of these bugs directly affect the code in the book or any of the example code.

You do need to be aware of some important changes in this seemingly minor update. The biggest change is that you must have Silverlight 4 installed now to use IronPython Silverlight Web Page template (see the Python Tools for Visual Studio (PTVS) Released post for details). I decided to try everything with Silverlight 5 now that it’s available and didn’t encounter any problems. Consequently, you may simply want to update to Silverlight 5 to avoid potential problems later.

The older IronPython Tools for Visual Studio tool is completely deprecated at this point. You must use the newer Python Tools for Visual Studio (PTVS) with IronPython 2.7.1. Since this newer product offers a wealth of useful features, it’s an easy update to accommodate.

For me, the best news is that IronPython is able to work with more of the Python Standard Library. Chapter 6 of my book discusses how to perform this task. Table 6-1 (page 99) contains a list of standard library modules that are missing from IronPython. That list is getting progressively smaller. IronPython 2.7.1 now supports these additional Python Standard Library modules:

 

  • unicodedata
  • csv
  • ats


There is currently an IronPython 2.7.2 Alpha release available as well. This new release isn’t far enough along for me to test with the book’s code as of yet. However, if you do test it out and find that you have questions about the book code when using it, feel free to contact me. I’m always more than happy to help out with book-specific questions.

 

Using Visual Studio 2010 with Start Here! Learn Microsoft Visual C# 2010

One of my goals when I wrote Start Here! Learn Microsoft Visual C# 2010 Programming was to provide a simple environment in which to learn C# programming techniques. Many books make the process hard or spend a lot of time with theory before you even get to write any code. In this book, you start creating applications almost immediately. Because most people reading this book would rather not spend a lot of money, I chose to use Visual C# Express. Since then, I’ve had a number of people write to ask me about using Visual Studio 2010 instead.

The short answer is that you can most definitely use Visual Studio 2010 with this book. However, it’s important to remember that the book is written using Visual C# 2010 Express. That means you’ll need to make a few adjustments, even though I did make an effort to create generic content that would work in a number of situations (in some cases, even with older versions of Visual C# Express). If you choose to use the book with a version of C# other than the one found in Visual C# Express 2010, you’ll probably see these differences.

 

  • The screenshots won’t match precisely. This is probably the most noticeable difference because every version of the C# IDE looks just a little different. When you work with a product other than Visual C# 2010 Express, you’ll need to look for screens that are similar, but not precisely the same as those you see in the book.
  • Some procedures won’t work quite the same. I’ve tried to do things like use the New Project link on the Start tab, rather than menu entries whenever possible. Both Visual C# 2010 Express and Visual Studio 2010 have the same link (in almost precisely the same position). However, there are situations where I must use menus and in that case, you’ll likely see differences. For example, Visual Studio has a File > New > Project menu entry (three levels), while Visual C# Express uses File > New Project (two levels). Differences like these could confuse some less experienced readers.
  • A few features could be missing. If you try to use this book with Visual C# 2008 Express or some other older version, you may find that it lacks some of the features I describe. When this happens, you need to work around the issue as best as you can. Unfortunately, the lack of feature support means that you might not be able to work with all of the examples.


I’m here to help you as much as I possibly can. Unfortunately, no matter how many computers I buy and load with software, there is a good chance that I won’t be able to match your setup precisely. We may have to exchange a few e-mails before I can locate the source of a problem that you’re experiencing. Always feel free to contact me about your book issues at John@JohnMuellerBooks.com, but once you do, please be patient as we through through any issues together.

You don’t have to wait until you have a problem to contact me. If you have anything to say about the book, positive or negative, I’d love to hear from you. Don’t forget to review my book on Amazon after you’ve finished. Your reviews will help other people make good buying decisions. As always, thank you for your support !

 

Resources for Rod Stephens’ Visual Basic Programming 24-Hour Trainer

I had previously reviewed Rod Stephens’ Visual Basic Programming 24-Hour Trainer. As part of that review, I had mentioned that Rod provides videos as one of the training methods. These videos add an element not found in most books—a real human talking with you about a particular technique.

For at least some people, the video is probably the most important addition to the learning environment because they actually learn better by watching someone else perform the task. Computer books now have the equivalent of cooking or woodworking shows on television. The popularity of these shows tells just how much people like them and you’ll like Rod’s videos quite a bit.

Fortunately, you don’t have to take my word for it, which is the purpose of this post. Rod has graciously made a number of these videos available online. As long as you can access YouTube, you can see the videos. Here’s the links:

 

Give these links a try to determine whether the video method works well for you. If you have any questions about the videos, you can direct them to Rod at http://lists.topica.com/lists/VBHelperQA. Make sure you check out Rod’s main Web site at http://www.vb-helper.com/ for additional resources. Normally, I won’t revisit a review, but in this case, I thought the additional information helpful and chose to share it with you.

 

Python Tools for Visual Studio (PTVS) Released

As mentioned in my IronPython Finally Has Visual Studio Support post several months ago, there wasn’t much support for IronPython in Visual Studio when I wrote Professional IronPython. In the months since then, I’ve looked at the test version of this product in a number of posts that you can read in the Professional IronPython category. Microsoft has finally released PTVS to the public. You can now use this stable release for development projects without worry.

I downloaded and installed this latest version. The first thing I did was to try and load a few of the projects found in previous posts. For example, I loaded the example from the Using Generics with Classes post and it appears to work fine. I also tried out the debugging techniques found in the Debugging Using PTVS and Debugging Using PTVS (Part 2) posts and they appear to work as before.

As far as projects are concerned, you get the same projects as with the test version of the product. However, you’ll notice that there is now a separate entry in the list for Python-specific applications as shown here.

PTVSReleased01

I tried creating a Windows Forms application and was disappointed to find that there is still no designer support. Of course, this means you still need to create your user interface using code and then test to see if it appear as you want it to. It would be nice if a future update (or perhaps a third party add-in) would make designer support available.

The one thing I noticed during my testing is that this version seems to work a bit faster. I didn’t perform any timed testing, but it seemed quicker and more responsive.

Future posts will look at the released version in more detail. If you’re already using the test version of PTVS, then you also know how to use the released version. It would be a good idea to update your copy, as needed, to ensure you have the latest bits. Be sure to write me about any questions or concerns about this release at John@JohnMuellerBooks.com.

 

Debugging Using PTVS (Part 2)

I received a comment on yesterday’s post, Debugging Using PTVS, that I thought I should explore in a bit more detail than a simple answer to the comment would allow. I want to extend my thanks to Dino Viehland for making me aware of this particular issue.

The first thing you need to know is that the version of PTVS that comes with IronPython 2.7 is outdated. So, when you’re asked whether to install PTVS with IronPython 2.7, you want to clear the selection. Simply set the Tools for Visual Studio option shown below not to be available.

IP2702

After you install IronPython 2.7, download and install PTVS from the CodePlex site instead. If you already have IronPython 2.7 installed with PTVS, I’ve found that the only way to truly get rid of the PTVS support is to uninstall it and start from scratch.

OK, on to the debugging part of this post. It turns out that you can change the debugging mode of PTVS by modifying the project properties. To perform this task, you choose Project > ProjectName Properties. If your Project Properties window looks like the one shown here, then you truly do have the old PTVS installed.

PTVSDebug201

However, if you see this version:

PTVSDebug202

you’re ready to go. Notice that the Debug tab has a Launch Mode field. This field controls how PTVS debugs your application. My initial post, Debugging Using PTVS, shows the IronPython (.NET) Launcher side of things. It turns out that you can change this setting to Standard Python Launcher, which significantly changes the behavior of the debugger.

The down side firstyou lose the ability to debug other .NET code. All you see when using this launcher is the Python world.

Now for the good part. My previous post showed how the call stack looks. It’s barely readable, but only if you squint a bit and think about it for a second or two. When working with the Standard Python Launcher, the call stack is significantly easier to read. Check it out:

PTVSDebug203

In addition, you’ll find that the Immediate window is a bit more cooperative too. Remember that it wasn’t possible to type ? args[0] without generating an error in yesterday’s post. When working with the Standard Python Launcher you get the expected result as shown here:

PTVSDebug204

In fact, you’ll find that debugging Python-specific code becomes easier when using the Standard Python Launcher. So, using the newer version of PTVS gives you some significant debugging flexibility that developers really need to create great IronPython applications. Let me know your thoughts on the updating debugging functionality at John@JohnMuellerBooks.com.

 

Debugging Using PTVS

A reader recently wrote to ask about the debugging features provided by PTVS. In Chapter 12 of Professional IronPython you discover techniques for debugging your IronPython application. This chapter doesn’t include any information about PTVS because the product wasn’t available at the time of writing. However, the techniques described in the chapter work just fine in Visual Studio too. What PTVS does provide is some additional debugging functionality that isn’t available to IronPython developers normally and that’s the topic of this post.

This post begins with the example created in the Using the PTVS for a Windows Forms Project post so that you can easily follow along. Of course, the techniques I describe are useful for any application you might be working on at the moment.

One of the first things you should look at is the Output window. It shows you everything that IronPython is loading in order to run your application. This information can help you locate potential issues in running an application on a client system and help you create the appropriate installation support for your application as shown here.

PTVSDebug01

As with any other Visual Studio application, you can set breakpoints for your IronPython application to stop execution at a particular point. To set a breakpoint you can click in the left margin. It’s also possible to right click a particular line, select the Breakpoint menu entry, and choose from the options on the menu. PTVS even provides full support for the usual assortment of conditional breakpoint offerings as shown here. (For the purposes of this post, I set a breakpoint on the MessageBox.Show(‘Hello!’) line of code.

PTVSDebug02

When your application stops at a breakpoint, you have access to many, but not all of the Visual Studio features. So far I haven’t been able to get the Autos window to work. (If anyone has a trick to make it work, let me know.) The Locals window does work though and provides the full range of information you’d expect. Here’s an example of the information you’ll typically see.

PTVSDebug03

Notice that you can drill down into the arguments as needed. It’s also possible to change values using the Locals window, just as you can with Visual Studio normally. Changes to many properties and variables work fine. However, you might not be able to count on this behavior for all value types. Visualizer support is there as well. At least, the Text, XML, and HTML visualizers seem to work. There may not be any support for custom visualizers.

The Call Stack window works much like it does for any Visual Studio application. Of course, the information is IronPython-specific as shown here.

PTVSDebug04

One bothersome aspect is that the window doesn’t tell you the correct language. Instead, you see that the language is marked as Unknown. The debugger does get the line numbers correct and it’s easy enough to decipher the remaining information in this window. You’ll find that the Call Stack window correctly marks any arguments to methods for you.

The Immediate window only partially works. At least, I found it worked only partially for me. For example, if you type ? args and press Enter, you’ll find that the Immediate window correctly tells you that it’s a tuple containing two items. However, it appears to be impossible to access the elements within tuple. For example, if you type ? args[0] and press Enter, you’ll find that the Immediate window responds with an error message as shown here.

PTVSDebug05

Making things a bit more difficult is the fact that you can type ? $function and press Enter to obtain the function-specific information and type ? $function.__name__ and press Enter to obtain the function name. In this case, everything works as expected. The debugging support provided by the Immediate window seems spotty. You may find yourself limited to performing certain tasks using it and then relying on the Locals window to perform other tasks.

There are other windows supported by the debugger that appear to work as you think they should. For example, you can set watches and view them using the Watch window, just like any other language that Visual Studio supports. The Breakpoints window also seems to work as it should.

This has been a whirlwind overview of the debugging features provided by PTVS to IronPython developers. Let me know if you have any specific questions at John@JohnMuellerBooks.com and I’ll do my best to research them.

 

Getting the Right Visual Studio Add-In

Give me the right tool and I can use it to create just about anything in code! It’s a bold statement and I’m sure that I’d have little trouble finding a lot of other developers who believe precisely the same thing. Unfortunately, finding the right tool is akin to finding a needle in a haystack (feel free to substitute any other worn cliche you can think about). How does someone quantify the usability of a tool or decide whether to even download it in the first place. I recently wrote an article for Software Quality Connection entitled, “Techniques for Finding Useful IDE Add-ins” that answers that question. The article proposes some techniques you can use to make the process of finding just the right add-in easier.

Of course, my great add-on is a piece of junk for you. Our needs, goals, programming skills, and programming tasks differ. So, what I’d like to know is how you look for add-ins and how you use them to create better applications. It’s nice to get another perspective on a given topic. Over the years I’ve talked with hundreds (perhaps thousands) of readers about the tools they use because the right tool in the right hands can do amazing things. Most of my books contain a healthy number of links to various tools and I often employ add-ins in my books to make tasks easier. Let me know about your favorite add-in and tell me why you think it’s so great at John@JohnMuellerBooks.com. (Please, no vendor e-mails. I already know your tool is great; I really want to hear from people in the trenches on this topic.)

Part of my reason for asking this sort of information is to improve the quality of my books and articles. Quality is extremely important to me. In fact, it’s the reason I created the beta reader program. A beta reader reviews my manuscript as I write it. You can find out more about the beta reader program in my Errors in Writing post. If you want to become a beta reader, just write me at John@JohnMuellerBooks.com for additional details. In the meantime, try out some new add-ins and have a bit of fun .

Using the PTVS for a WPF Project

As with Silverlight, there is no mention of theWindows Presentation Foundation (WPF) in my book, “Professional IronPython.” The WPF is supposed to help solve some display problems for application developers and allow better use of modern graphics processors. Microsoft has provided a significant amount of information about the WPF that I won’t be discussing in this post. Whether you find WPF helpful or not depends on the kind of applications you create. I’m sure that WPF will find use in game applications, widgets of various sorts, mini-applications, and a host of other uses, but I’m not sure just what it adds to the common business application, such as a data entry application. Still, WPF is an exciting new technology that you should investigate.

As with the Silverlight project in my previous post, you need to have the PTVS installed on your system to work through this example. To begin this example,
you start Visual Studio as normal and choose File | New to create a new
project. The New Project dialog box should contain an entry for a Wpf Application template as shown here. If you don’t see
this template, then you probably don’t have IronPython 2.7 installed on
your system and can use the instructions found in the IronPython 2.7 and PTVS blog entry to install it.

WPF01

The example will accept the default name for the project. Of course, you can use any name that you’d like. Click OK. You’ll see a new WPF application. However, for some odd reason, the eXtensible Application Markup Language (XAML) (pronounced zammel) file doesn’t always open, so you’ll have to open it manually. At this point, you’ll see a project similar to the one shown here.

WPF02

The top half of the designer shows what the page will look like, while the bottom half shows the associated XML. As you add controls to the form and configure them, you’ll see the changes in the XML, making it easy to code changes to the controls when necessary. Of course, you can choose to display just the Design window or just the XAML window if desired. Depending on the amount of screen real estate at your disposal, collapsing one of the panes by clicking Collapse Pane at the right side of the window, may be a good idea.

One of the advantages of using WPF is that you have immediate access to the Ribbon without having to employ any odd programming techniques. You just drag and drop the Ribbon controls from the Toolbox as you would any other control. Here’s a subset of the default set of WPF controls you can access from IronPython.

WPF03
As you can see, the set of controls is rich and you do have access to others, so WPF may be the way to go for IronPython developers who need maximum control access.

The example isn’t going to do anything fancy. I’ve added two Button controls to the form. Here is how I set the various properties using XAML:

<Window
   Title="WpfApplication1" Height="300" Width="300">
   <Grid>
      <Button Content="Click Me"
              Height="23"
              HorizontalAlignment="Left"
              Margin="191,12,0,0"
              VerticalAlignment="Top"
              Width="75"
              Uid="btnDisplay"
              Click="btnMessage_Click" />
      <Button Content="Cancel"
              Height="23"
              HorizontalAlignment="Left"
              Margin="191,41,0,0"
              VerticalAlignment="Top"
              Width="75"
              Uid="btnCancel"
              Click="btnCancel_Click" />
   </Grid>
</Window>

The first button displays a simple message box, while the second ends the application. Each Button control is assigned basic visual properties, a name, and an event handler for its Click() event. One thing I dislike about working with WPF is that the Properties window doesn’t display any quick help for the various properties. You need to know what each property does or look it up, which is really inconvenient.

The code behind for this example relatively simple. As previously mentioned, the first control displays a message, while the second closes the application as shown here:

import wpf
 
from System.Windows import Application, Window, MessageBox
 
class MyWindow(Window):
    def __init__(self):
        wpf.LoadComponent(self, 'WpfApplication1.xaml')
     
    def btnCancel_Click(self, sender, e):
         
        # End the application.
        MyWindow.Close(self)
     
    def btnMessage_Click(self, sender, e):
         
        # Display the message on screen.
        MessageBox.Show("Hello")
     
if __name__ == '__main__':
    Application().Run(MyWindow())

Much of this code is automatically generated for you. In order to use the MessageBox class, you must add it to the import statement as shown in the code. The code begins with the initialization, which simply loads the components from WpfApplication1.xaml.

The btnCancel_Click() event handler relies on the MyWindow object’s Close() method. Make sure you pass a copy of self as part of the call.

The btnMessage_Click() event handler makes a call to the MessageBox.Show() method with a simple text message. You’ll see the dialog box appear as expected.

From what I can see, the WPF support for IronPython in PTVS is on par with WPF support for any other .NET language. It has the same limitations and benefits as any WPF application will have. So, what do you think of the new WPF project support provided by PTVS? Let me know at John@JohnMuellerBooks.com.

 

Rod Stephens’ Visual Basic Programming 24-Hour Trainer

Learning a new skill, such as programminglearning it quickly and easily, is much harder than it sounds, but “Rod Stephens’ Visual Basic 24-Hour Trainer” makes the task considerably easier. The book begins with possibly the best Introduction I’ve ever seen. The author tells you precisely how to use his book to learn how to code in Visual Basic in a short interval. Additionally, he makes it clear what the book won’t tell you. This is most definitely a book for the rank beginnersomeone who has never written code before and the author makes it clear that better educated developers need not apply. (More advanced readers will benefit more from another of Rod’s books, “Visual Basic 2010 Programmer’s Reference“.)

The chapters tell you how to perform most basic tasks associated with desktop applications. You won’t find any Web development techniques in this book, but the author makes that clear in the Introduction. The reason for focusing on the desktop is that it provides a controlled environment that works anywhereno Internet connection required, no special setup needed. All you need is your system and Visual Basic.

The first chapter is the usual description of how to get Visual Basic installed on your system. Rod discusses a few different options and doesn’t wimp out by covering only Visual Basic 2010 Express Edition like many beginner books do. Because of the target audience for this book, Visual Basic 2010 Express Edition works fine.

The book takes the usual college approach of starting with a basic application, working through variables and structures, and then moving toward more complex application types. You learn all of the basics of working with classes, printing documents, working with the clipboard, and other usual fare for a book of this type. Rod does provide a couple of nice perks such as working with LINQ and databases using the entity framework. The goal is to learn how to use Visual Basic at a basic level, so these exercises will serve the reader well. Someone looking to start by creating a relatively complex example almost immediately will be disappointed. I know that some readers look for this approach now and Rod’s book definitely won’t serve their needs; this book is more traditional (and proven) in its approach.

Each of the chapters provides several methods to learn the material. You can read about the technique, try it yourself on your machine, work through exercises, and even watch a video. Most readers will find a technique that works well for them. Rod suggests using some or ideally all of the techniques to obtain a better learning experience.

The videos are a nice touch and Rod does them well. The longest video I watched came in at 17 minutes, the shortest at 4 minutes. He has a nice speaking voice and an easy manner of approaching the topic. The reader should definitely feel at ease during the presentation. Rod doesn’t resort to humor to cover up a lack of depth in his book. It’s not that he’s incredibly serioushe’s simply straightforward and businesslike in his approach.

Will you actually get through this book in 24 hours as the title says? I doubt it. I tried out a number of the chapters and found that I averaged about an hour in doing them fully (including the exercises) at a rapid pace. There are 39 chapters in the book for a total of 39 hours of training as a minimum. Even if you attack the book at a rabbit-like pace and skip some of the features, you still won’t get through it in 24 hours and manage to gain anything worthwhile. I’d suggest setting aside at least 40 hours of focused time to get through this tome.

The bottom line is that this is a great book for the rank novice to learn a new skill and discover the joys of programming. It’s not the sort of book that anyone who has written code before will want and it’s also not the sort of book that the impatient reader will find helpful. Rod has done a marvelous job of presenting a complex topic in a manner that will help most people get up to speed working with Visual Basic in a short time.