Connect With Us

Adam T. Stallman

Adam T.

Adam T. Stallman is a member of the iSeries Journal Development Team at IBM Rochester.

Document Code, See the Results 
Of all the features of the .NET programming languages that I most enjoy, XML documentation comments is near the top of my list. You can easily see the results as you develop code. For example, Figure 1 shows the IntelliSense prompting that Visual Studio displays for a method I created named T4Trace.BeginMethod. The IntelliSense prompting shows the return value (void) and the types and names of the parameters. This example shows the IntelliSense that is displayed when I do not have XML documentation in my code. Figure 2 shows the code for the method with the XML documentation. The code example is C# and the XML documentation comments start with the /// characters. The equivalent in Visual Basic is to enter three consecutive single quote characters. As soon as you enter the XML document characters (on the line immediately above a class, method, or member definition statement), Visual Studio generates the initial documentation statements. I then added the descriptive text (Figure 2). After adding the XML documentation, I now see the documentation displayed in IntelliSense (Figure 3). The descriptive information shown is taken from the summary section of the XML documentation. In this example, you might argue that the documentation isn't really necessary. After all, the method name and its parameter names are fairly self-explanatory. There is a school of thought that suggests using proper names is really all you need, and if you need to understand more about how to use the code, you should just read the code itself. Taken to an extreme, you should imagine how difficult it would be to work with .NET if there was no MSDN documentation for the .NET Framework itself. My opinion is that Visual Studio makes it so easy to enter the documentation that there is no reason to not add the appropriate comments as the code is being entered. Indeed, there is a tool (GhostDoc) that makes generating documentation even more automatic. As wonderful as XML documentation is, it gets ev
Encrypt Connection Strings in the Web.config File 
When you develop an ASP.NET application using Visual Studio, you usually end up with one or more connection strings in the Web.config file for the application. The connection strings might contain sensitive information, including user IDs and passwords, stored in plain text. Because the Web.config file must be included with other files in your application when you deploy the application, you will probably want to encrypt the connection strings in the file. Figure 1 shows an example of a Web.config file that contains four connection strings. Using the steps shown in this article, you'll see how the connection strings can be encrypted. Encrypt Connection Strings, Test on Your PC To encrypt the Web.config file, you'll be working with the aspnet_regiis program, a utility program that is installed with Visual Studio. You need to know the full path to the Web.config file to encrypt it. In the Visual Studio Solution Explorer, select the Web.config file and look in the Properties panel for the Full Path property (if you don't see the Properties panel, press F4 after clicking the Web.config file). Now go to the Windows Start menu. Navigate into the Microsoft Visual Studio 2010 program group, then into the Visual Studio Tools folder. Start the Visual Studio Command Prompt program. Enter the following command in the Command Prompt window: aspnet_regiis -pef connectionStrings path_name Note: You must enter the value connectionStrings using the exact case as shown here. That is how it is specified in the Web.config file. Note: for path_name enter the drive letter and path to your Web.config file. Do not include the file name Web.config in the path name. You should see the Succeeded! message (Figure 2). If you do not see the message, check the syntax of the command and the parameter values that you entered. Now go back to Visual Studio and open the Web.config file. You will see that the <connectionStrings> element content has been encrypted (Figure 3). Reb
IBM .NET Provider in Visual Studio 2010 64-bit Edition 
By default, the IBM .NET Data Provider is not displayed in the Visual Studio 2010 Choose Data Source dialog (Figure 1). The Choose Data Source dialog is used in Visual Studio when you use its tools to create database connections. In three previous articles in My i-.NET, I've written about a fix that IBM provided for Visual Studio 2008 (32-bit and 64-bit editions), and a fix provided by Richard Schoen of RJS Software for Visual Studio 2010, 32-bit edition. The articles are: Add the IBM Provider as a Data Source in Visual Studio 2008 (describes the VS2008 32-bit support) Update to IBM Provider as a Data Source in Visual Studio 2008 (describes the VS2008 64-bit support) Add the IBM Provider as a Data Source in Visual Studio 2010 (describes the VS2010 32-bit support) I recently contacted Richard and asked if he had an update for the VS2010 64-bit edition. He promptly and generously provided the following link, and makes this freely available to all who are developing for IBM i using the .NET Provider: The zip file contains two .reg (registry entry) files. Unpack the zip file to a directory, then simply double-click each of the .reg files to update the registry on your PC. Note: before running these files, you may want to backup your registry. You can use the regedit program on your PC and select the File, Export option to export the registry. In my install test, I closed all the open programs on the PC, then installed the two .reg files. I then rebooted the PC and started Visual Studio 2010. After restarting, I was able to select the IBM .NET Provider (Figure 2). I tested this configuration with IBM System i Access for Windows V6R1M0, 64-bit edition, with Service Pack SI41053. Once again, I sincerely thank Richard for making these important updates available to the community. If you download and install either of his contributions (the 32-bit or the 64-bit editions), take the time to expre
Resolve a .NET Provider Error in Visual Studio 2010 
One of the consequences of leading SystemiNetwork eLearning courses for .NET development is that I get to hear from many people about their experiences with Visual Studio, database providers, and problems that they run into. Earlier this year several people reported a problem in the web development track. That track is again in progress, and I am hearing about the same problem. However, I haven't been able to reproduce the problem in my environment. As any developer knows, that is one of the worse situations to be in. Fortunately, in the earlier track, one of our participants (Alex K.) provided a solution to the problem. In this article, I provide an overview of the problem and the solution. You can read through the overview first and check things out on your system. If you don't see the problem, then you should be all set to use the IBM .NET Provider in your Visual Studio 2010 projects. If you do see the problem, continue with the steps described in this article. If you can provide an explanation of how to reproduce the problem, I will add that explanation to an update for this article. The Way Things Are Supposed to Work Assume that you are in Visual Studio 2010, and you are using the tools to add a data source to your project. There are many places from which you can add a data source in Visual Studio. For example, when you add a grid control to a Windows Form or a web form, you can visually configure it to add a new data source. Figure 1 shows the Choose Data Source dialog; with the IBM .NET Provider selected (if you don't see the IBM .NET Provider listed as an option, be sure to check out this issue's companion article to learn about registry entries that must be set to display the provider). After selecting the provider, you advance to the next dialog (Figure 2), where you set properties for the provider. That is the expected behavior; after setting the properties, you can develop the rest of your application using the connection. The error that is be
HATS-off to IBM modernisation? 
Big Blue released Host Access Transformation Services (HATS) V8 on August 9. iNEWSWire UK asked regular contributor Lionel Butler to take a look under the covers.
How to Work with a Multiple Result Sets Stored Procedure 
In my experience, working with stored procedures in an application is like exercise. I know I should be doing it more often, and I really intend to start using stored procedures on a regular basis. But in the next program, it's so much easier to just code the SQL statements right in the program and get on with it. In my defense, if I really only need one SQL statement in a program, it's easier to directly code the SQL inline. But I'm finding that many of my applications use more than one SQL statement (I mean SQL SELECT statements). In those programs, I have many sections of code where I create a command, execute it, then work with the returned data. In an application where there are two or more SQL SELECT statements, it makes sense to consider using a multiple result sets stored procedure. The idea is that you can define the SELECT statements in the stored procedure. You then call the stored procedure from your program, rather than executing multiple SQL commands to run the SELECT statements. Upon return from the stored procedure, you have access to the result sets that are the result of running each of the SELECT statements. If you haven't used this technique before, this month's example shows that the code needed to work with multiple result sets is trivial. Create a Multiple Result Sets Stored Procedure There are several ways you can create a stored procedure on your IBM i. I'll show you the technique I used, working with the IBM i Navigator in the Databases section. After navigating into the schema (library) that I wanted to work with, I selected the option to create a new SQL procedure. The New SQL Procedure panel shown in Figure 1 is displayed. To create a multiple result sets stored procedure, you need to enter the procedure name and specify a value for the maximum number of result sets. Because I will be using two SQL SELECT statements in the stored procedure, I enter 2 as the value for the maximum number. That does not mean that you have to return
From the Bookshelf: The Art of Unit Testing 
One way or another, all software that is put to use gets tested. In most of my projects, testing is usually an ad hoc affair where I make the program jump through whatever hoops come to mind. Users, in their ignorant blind trust, disregard my instructions on how to use the program and discover entirely novel ways to destroy what was, in my hands, a working application. Over the years, I've developed my own strategies for testing, centered on console applications. In The Art of Unit Testing with Examples in .NET (Manning, ISBN 1-933988-27-4), author Roy Osherove gently shows why that individualistic approach to testing is wholly inadequate, and why using a unit testing framework is the only sensible approach to take to get a handle on producing better applications. In Chapter 1, Roy quickly identifies the differences between unit testing and integration testing. For example, if you develop a GUI or web application that calls code in a back-end class and test that class through the GUI, you are performing integration testing, not unit testing. The focus of unit testing is on testing your code at the individual-method level, with tests that can be easily created, run, maintained, and understood. Roy shows how to use the NUnit test framework to develop tests for .NET applications. This book was released in 2009, prior to the release of Visual Studio 2010 with all of its newly enhanced test features, but it's safe to say that developing a working acquaintance with NUnit is a valuable skill. The book shows how to get started with NUnit and goes on to cover many of the situations that you'll need to resolve to create tests with complete coverage of your code. The final two chapters of the book may be the most valuable in terms of positioning testing within your development process. In those chapters, Roy lists many of the questions and objections that you will be confronted with when you introduce testing into your development environment. He also discusses how testin
What's the Difference? 
In and of itself, a date field is not complicated. It contains a date value and a time value. If dates were always used in isolation (for example, "I was born on this date"), the date could just as well be stored in separate year, month, and day fields, just as we used to do before date fields were added to our programming languages. But dates are seldom used just by themselves. As soon as you have a date value, you almost always need to know if it is sooner or later than another date. To make it easy to perform date calculations, IBM includes date operation codes (ADDDUR and SUBDUR) and the %DIFF built-in function in RPG. The equivalent operations in .NET are performed using methods of the System.DateTime and System.Timespan structures. To show how the .NET operations are used, I started with the ILE RPG Reference manual for i 7.1. The description of the %DIFF BIF includes Figure 207, which shows how to calculate the difference between two dates. I transposed the RPG example to the Visual Basic code shown in Figure 1. The results of running the Visual Basic code are shown in Figure 2. Code Analysis To make it easier to follow along with the code analysis, I added section identifiers in the comments. For example, section identifier [A] is near the beginning of the program shown in Figure 1. In Section [A], three fields are defined. They correspond to the first three fields defined on the D-spec in the RPG example. An RPG "D" date type is defined as a System.DateTime type in .NET. When defining a DateTime field, you can initialize just the date part (as shown in Section [A]), the time part, or both. In this example, the time part is not initialized so the default time value of 12:00:00 AM is assigned to both DateTime fields. The num_days field is defined as a System.TimeSpan type. In RPG, the field is defined as a numeric field: the %DIFF BIF calculates the value to assign to the field based on the specified interval type (*DAYS, *MINUTES, etc.). In .NET, a T
Weak Software, Visual Studio Service Pack 
Programming is hard work. Just getting the computer to do what you need it to do can be a lengthy and aggravating process. Once you have something working, it is axiomatic that users will start reporting bugs right away. If you're writing programs that are used on the Internet, you have another, whole class of "users" to deal with, who have made it their business to try to disrupt your business. I recently came across a document named "2011 CWE/SANS Top 25 Most Dangerous Software Errors." CWE stands for Common Weakness Enumeration, and the SANS Institute (SysAdmin, Audit, Network, Security) is an organization that has been around since 1989, promoting research and education in computer-security related topics. Most of the time, when I read through a discussion of security, I realize I am in over my head. That is not a good position to be in when developing Internet applications, because innocent misunderstandings can lead to disastrous consequences. However, the Top 25 document is different. Each error is introduced with a short, one or two paragraph description that is easy to read and understand. Following that is a list of prevention and mitigation techniques, written in an easy-to-understand style. The weaknesses are described in order of their score, using a scoring system developed for the document. The top weakness is SQL injection, which typically occurs when SQL statements are constructed based on user inputs. The Top 25 document is not language or platform specific. That said, some of the weaknesses may not apply when you use certain languages or operating systems. Many of the weaknesses occur based on the use of JavaScript in web applications. You may find it useful to spend a few minutes looking through the Top 25 document. Just knowing how a certain weakness occurs may be enough to help you avoid creating software with that weakness. Visual Studio 2010 Service Pack 1 If you're using Visual Studio 2010, you may want to download and install
Enterprise .NET and InfoQ 
One challenge of programming in a framework-based environment like .NET or Java is that it's possible to learn how to use the programming language but still not be entirely sure of how all the pieces fit together. After working with .NET for a while, it seemed to me that Visual Basic and C# were used primarily to orchestrate components of the framework. But just learning more and more about the .NET Framework also did not seem to be the whole story. The .NET Framework is so monumentally huge that it is unlikely that anybody can become conversant with all of it; we tend to specialize in various parts of the framework that are most applicable to our daily needs. But even after winnowing down the framework to the essentials for the tasks at hand, there's still a nagging feeling: Am I doing this right? Architecting Applications for the Enterprise Microsoft .NET: Architecting Applications for the Enterprise (Microsoft Press, ISBN 0-7356-2609-X) by Dino Esposito and Andrea Saltarello is, for me, the ideal "how to put it together" reference. This book came out in 2009 and is oriented towards the Framework 3.0/3.5 timeframe, but I don't find it lacks anything by not covering Framework 4.0 features. Although the book has many code examples, it is not a book about how to write .NET programs; the assumption is that you are already up-to-speed with the basics of your language, tools (Visual Studio), and the fundamentals of the .NET Framework. The book makes liberal references to many patterns and practices that are common fodder for computer science discussions, but unlike the computer science treatment, the book shows how the patterns are applied and put to use when developing real-life applications. Dino Esposito is a well-known author and is regularly featured in MSDN Magazine. His writings about .NET are valuable, as he has a knack for taking new and potentially confusing topics and making it clear what problem is being addressed and how to use the feature he is desc
Edit Code Cheat Sheet Simplifies .NET Equivalents 
Back when I wrote RPG programs on a daily basis, I had two pieces of paper taped to my terminal. One had a quote attributed to Gandhi: "Whatever you do will be insignificant, but it is very important that you do it." The other piece of paper was cut out of an RPG O-spec coding pad. It was the summary chart of the RPG standard edit codes. As a historical footnote, an "O-spec coding pad" was a pad of about 50 sheets of paper, each of which had a grid showing the columnar breakdown of an RPG O-spec. The idea was that an RPG programmer would write out their O-specs on the grid, then go to the card punch machine and punch the deck ... this is getting too complicated. Just know that back in the day, there was a small edit code summary that I cut out of one of the O-spec sheets and taped onto my terminal, so that I wouldn't have to memorize the edit codes. Edit codes are still with us, and are used on O-specs (still) and in DDS specs. One of the problems you might run into when you program in .NET is trying to figure out what the equivalents are. This month I put together a Visual Basic program based on a chart in the IBM ILE RPG Reference manual. The chart is in the i 7.1 version of the reference manual, Table 40, Examples of Edit Code Usage. Prior to creating my Visual Basic test program, I created a small RPG program that simply printed the values for each edit code, as shown in Table 40. Be aware that Table 40 contains three typo errors. In the second column (Positive Number—Two Decimal Positions), the values for edit codes B, K, and O show a comma as the decimal separator character where a period should be used. My RPG example program proved what the results of the edit codes should be and served as a check on the typos. Using Table 40 as a guide, I created the Visual Basic program shown in Figure 1. The output of the program is shown in Figure 2, Figure 3, and Figure 4. The program defines six Decimal fields, using the values shown in the IBM example. I th
Get Started with WCF in 5 Minutes 
Using tools in Visual Studio 2010, you can get a quick look at a Windows Communication Foundation (WCF) service in just a few minutes. Granted, the quick overview doesn't do any real work, but you can see the organization of the code that you'll use in a WCF application. Better yet, you can run the WCF service and interact with it using a built-in test tool. To get started, open Visual Studio 2010 and start a new WCF Service Library project, as shown in Figure 1. You can start a Visual Basic or C# project—either language generates code that is equivalent to the other and uses the same test tool. Visual Studio creates the project and adds two source files to it: IService1.vb (or IService1.cs) and Service1.vb (or Service1.cs). Figure 2 shows a split-view of the files in Visual Studio. The IService1 file contains the definition of the ISerivce1 interface. The interface is decorated with the ServiceContract attribute, and its members (functions or methods) are decorated with OperationContract attributes. Those attributes are used by WCF to determine the names of the service methods, the parameters for the methods, and the return values from the methods. The IService1 file also contains a class named CompositeType. The class is decorated with the DataContract attribute and the class members (properties) are decorated with DataMember attributes. Those attributes are used to enable the class for use within WCF. The GetDataUsingDataContract service method (defined in the IService1 interface) passes the CompositeType as a parameter and returns it as its return value. The Service1 file contains the class Service1, which implements the IService1 interface. A class that implements an interface contains the functions or methods that perform the actual work provided by the service. As you can see in the sample code, the methods are trivial and don't really do anything useful. On the surface, having Visual Studio generate those two source files might be a big "ho, hum.
Moving on from PDM 
For over 20 years, PDM has been the main day-to-day environment for most RPG developers, with little change or enhancement.
From the Bookshelf: Professional Visual Studio 2010 
I wasn't even looking for this book. I started out looking for a book that had information about the Managed Extensibility Framework (MEF), and this book popped up in the search. I decided to buy it because it also covers other topics in which I have some interest. Am I glad I did. This is one of those "monster"-sized computer books: nearly 1200 pages, 57 chapters. After reading through several sections, I think it can be considered not as one book, but rather, a collection of 57 shorter books all in one. Your initial inclination—based on the title—might be, "How can there be such a big book about Visual Studio? After all, it's just code editor, right?" Indeed, based on my complete reassessment of Visual Studio 2010 after reading through this book, I confess that I had slipped into the same comfortable familiarity with Visual Studio. I knew enough about it to wrangle code, organize projects and solutions, and use features that mattered to me in day-to-day programming. What I clearly did not know, and this is why this book is an outstanding value, is just how much more programming power is available within Visual Studio. I am not normally given to gushy superlatives about computer books. I have many and tend to use them for reference rather than for reading straight through. My preference is to use books instead of web pages or help files to try to learn about new things. In this case, this book brought me up short and showed me just how little I knew about what was going on in the newer versions of the .NET Framework and how Visual Studio can help accelerate the use of new features. Some programmers are not fond of Visual Studio. I have heard some propose that the "best" way to develop .NET applications is to simply enter code in a lightweight editor (even Notepad is suggested), and use the command-line tools to compile your programs. After all, Visual Studio simply generates source code, so why not remove the bulk and the overwhelming plethora of "us
Getting Started with IIS 7.5 Express Web Server 
One of Visual Studio's great features (since Visual Studio 2005) is the built-in web server test environment. When you develop a web or web services application in Visual Studio, you can simply press F5 to start it running. The built-in web server starts and displays your application in your browser. For most web applications that you develop, you can use the built-in web server for your development and testing requirements. The disadvantage of using the built-in web server test environment is that there are no customizations available to you, and you are limited to using only features and functions provided by the web server test environment. For example, you cannot test https (secure) web serving. If you don't have a test web server that is running Internet Information Services (IIS) 6.0 (Windows Server 2003), IIS 7.0 (Windows Server 2008), or IIS 7.5 (Windows Server 2008 R2), you can download and install the no-charge IIS 7.5 Express web server from Microsoft. IIS 7.5 Express provides the functionality of the IIS 7.5 web server that is provided with Windows Server 2008 R2. It gives you complete access to the configuration files used by the web server. And you can customize all aspects of the web server so that you can test how your web application will work before deploying it to the live web server. Download and Install IIS 7.5 Express You can download and install the IIS 7.5 Express web server in a matter of minutes. Go to and search for IIS 7.5 Express. On the search results page, select the item for the IIS 7.5 Express download. You should be taken to the download page (Figure 1). You can save the downloaded file and run it, or start it running as part of the download. The download file is less than 4MB in size. Use IIS Express as Your Test Web Server After downloading and installing the IIS Express web server, you can use it with your web applications in Visual Studio (Note: the following steps and figures are shown using Visual Stu
iPro Forums

Get answers to questions, share tips, and engage with the iPro Community in our Forums.

From the Blogs
Application Modernization Redbook Unleashed
Mar 27, 2014

Application Modernization Redbook Unleashed  

The Application Modernization Redbook draft version has been released! Tim Rowe has the details....More
Free-Form RPG Transformation, Part 2
Mar 19, 2014

Free-Form RPG Transformation, Part 2  

Tim Rowe continues his series on ISV tools for free-form RPG with a look at Linoma Software's free-format transformation tool, RPG Toolbox....More

Sponsored Introduction Continue on to (or wait seconds) ×