Home

Upgrading Microsoft Certifications

11

August

I am a Microsoft Certified Solution Developer (MCSD.) Seeing as some of the folks at work are looking to get their certifications, I spent some time today reviewing possible tracks to upgrade my credential to Microsoft Certified Technology Specialist (MCTS) or Microsoft Certified Professional Developer (MCPD.)  I was happy to discover that I am eligible to upgrade my MCSD credential with the option of one or two exams.

If you (like me) are an MCSD, you can earn certifications in MCTS: .NET Framework 2.0 Web Applications, MCTS: .NET Framework 2.0 Windows Applications, MCTS: .NET Framework 2.0 Distributed Applications, and MCPD: Enterprise Applications Developer on Visual Studio 2005 by passing Exam 70–554 and Exam 70–553

Alternatively, you can receive your MCPD: Enterprise Applications Developer by passing a single exam, Exam 70–554, but you will need to earn your MCPD: Web Developer and MCPD: Windows Developer certifications first. This option is certainly the faster track if you have already satisfied the two prerequisite certifications (which I have not.) 

MCPD: Database Administrator

You will note the exams called out above are geared around Visual Studio 2005 and the .NET Framework 2.0.  There are also equivalent MCTS and MCPD certifications for Visual Studio 2008 and the .NET Framework 3.5.  I’ve been inside of VS 2008 and .NET Framework 3.5 for some time now so I may just test my skills against the latest and greatest.  It seemed to make sense but you never know.

It’s been over 4 years since I last tested.  If anyone has advice or feedback, I would love to hear it — even if it’s merely "good luck."  


Assembla - Accelerating Software Development

07

August

A good while back, I commented about SVN Hosting through SVNRepository.com.  Well, I am still using SVN Repository but I came across another option, Assembla, last week and it deserves some attention.

Though many SVN repositories provide an accompanying Trac instance, that’s about all they do.  Frankly, that’s because that’s all they need to do. Assembla is the exception.  It takes hosting one step further.

Assembla is a complete software development tools package offering workspaces to thousands of teams for FREE.  The screenshot below gives you an idea of what is provided.  There’s everything from a SVN, Git or Mercurial repository to a project-specific Wiki and Chatroom.  If you look around, you will even find a Time Tracking application.

image

You may add team members to your Workspace with different privileges as well as establish security settings for non-member access.

image 

Creating a space is low friction…just visit the home page, click "Create a new space" and follow the instructions.  The free account includes all of the core functionality and is limited to 200MB of storage.  If the free account doesn’t meet your needs, Assembla does also provide commercial and branded options which include further functionality and support in exchange for cash money.  You can find out more about Assembla plans on their tour page.

I recommend creating a free account and clicking through the tools as Assembla may be a good option for you. 

kick it on DotNetKicks.com


.NET Podcast Recommendations

06

August

Last Friday, a fellow coder asked the team for podcast recommendations.  Since I listen to anywhere from 6-10 podcasts a week, I was happy to share what is currently in my top podcast rotation. 

It is worth noting that those of us in the .NET community are rather fortunate as there are a number of recent newcomers in this space.  In fact, four of my top six podcasts have been around for less than 4 months.  I personally think they’ve all done a standup job and it has been enjoyable listening to the podcasts as they mature.  Maybe some day, years from now, young developers will gather around as I tell tales of the very first Herding Code podcast. You never know…

Enough with the intro already.  Here’s my .NET Podcast Recommendation List in no particular order (other than alphabetical):

Alt.NET Podcast
http://altnetpodcast.com/
Hosted by Mike Moore
Currently on Episode 8 

Deep Fried Bytes
http://deepfriedbytes.com/
Hosted by Keith Elder and Chris Woodruff
Currently on Episode 8

Hanselminutes 
http://www.hanselminutes.com/
Hosted by Scott Hanselman
Currently on Show #124 

Herding Code
http://herdingcode.com/
Hosted by Jon Galloway, K. Scott Allen, Kevin Dente and Scott Koon
Currently on Episode 11

.NET Rocks!
http://www.dotnetrocks.com/
Hosted by Carl Franklin and Richard Campbell
Currently on Show #365

Stackoverflow
http://blog.stackoverflow.com/
Hosted by Jeff Atwood and Joel Spolsky
Currently on Podcast #16

kick it on DotNetKicks.com


iPhone Firmware Update

06

August

For my birthday, back in early July, I received an Apple gift certificate for the exact purchase price of a shiny new version 2.0 iPhone. Since I already own the first generation iPhone and I have a tendency to avoid ridiculously long, seemingly endless lines, I haven’t picked up my present yet.  Actually, the last time I even thought about cashing in my certificate was one week after the iPhone 2.0 launch.  At the time, the nearest Apple Store had multiple rows of chairs lined up outside of the front door.  These chairs, I discovered, were reserved for folks who had previously waited in line but didn’t get to the cashier prior to the product selling out.  I guess the customers were lucky enough to receive a ticket or voucher along with the privilege to wait in line again once the next shipment arrived.  So, I wasn’t even close to getting a new phone a week after launch and I haven’t made it back to the store yet.

What I have done, however, is upgrade my firmware which took roughly as long as some of those poor folks had to wait in line outside the store.  Perhaps I am jumping ahead, but don’t attempt to upgrade unless you have time.  I’m told some upgraded are completed within 30 minutes, but I, unfortunately, have 16GB of storage space on my iPhone and I am using over 90% of it so the backup and restore of my data alone took close to an hour.  That on top of a 218MB download and the upgrade itself makes for a long firmware upgrade.

All things told, I completed the firmware upgrade because I was very interested in playing around with the AppStore and, well, I had nothing to lose.  I will say I have found the upgrade to be of little value at this point.  Yes, I now have Pandora running on my phone which is cool although the app is clunky.   I have experienced the keyboard delays and more crashes (supposedly fixed with the 2.0.1 release which I haven’t installed yet) and sadly my email pulling is far, far, far less reliable now than ever.  In fact, I find myself often times rebooting my iPhone just to resolve issues. 

When I do get around to picking up my new phone, let’s hope everything works a little more smoothly.


Compile Help File Documentation Using Sandcastle

05

August

I am currently on the bench at work waiting for my next assignment to start up in a few days.  Rather than sitSandcastle Logo around, read blogs and listen to podcasts, I’m keeping myself busy by putting together the beginnings of a code library to be shared across our development team.  Yesterday I started the foundation.  I defined the framework, file system layout and basic namespace conventions.  I also created two class libraries and associated test projects to get the ball rolling.  I’m pleased with the way the common library is turning out.

Today, I refactored a bit and then focused on documentation.  Specifically, I generated help file documentation via the XMLSummary comments. I searched around and played with various utilities and ultimately decided on Sandcastle and Sandcastle Help File Builder.

Sandcastle.jpgSandcastle - Documentation Compiler for Managed Class Libraries, created by Microsoft, produces accurate, MSDN style, comprehensive documentation by reflecting over the source assemblies and optionally integrating XML Documentation Comments. Sandcastle works with or without authored comments and supports .NET Framework 1.1, 2.0, 3.0 and 3.5.  Sandcastle is, however, a command line based tool which has no GUI front-end.  That’s where Sandcastle Help File Builder (SCHB) comes in.  SCHB provides a user interface (as well as command line based tools) to facilitate the building of help files in an automated fashion. Both applications may be found on Codeplex.

Sandcastle (really Sandcastle Help File Builder wrapped around Sandcastle) is easy to install and navigate and I was able to quickly integrate into the common libraries’ best practices.  Now when additional code (new library, class, method, etc) is appended to our common code repository, team members simply need to follow the overall folder structure, code library templates/namespaces and update the Help File Builder project which is now in place. 

Below are the instructions on how to extend the existing Help File Builder project.  These instructions will be share with my team members though they can easily be altered to create a help file from the ground up:

  1. Download and install Sandcastle and Sandcastle Help File Builder from Codeplex.

  2. Apply XML comments to your code base. 
  3. Navigate to the Build Tab of your project’s properties and do the following:
    • Check XML documentation file
    • Set file name to bin\[mode]\assembly name.xml where [mode] is debug or release. Example: bin\release\MyCompany.Common.Serialization.xml
  4. Compile your assemblies in release mode.   Note: I’m opting to only generate documentation per the assemblies/xml generated in release mode although it doesn’t have to be this way.
  5. Run Sandcastle Help File Builder. The existing Sandcastle Help File Builder project can be found in the following location: MyCompany\Common\MyCompany.Common.shfb
  6. Add your compiled assembly to the SCHB project:
    • Click Add > Browse to the libraries’ bin\Release > Select dll
    • After the assembly is added, the dll and xml files will be listed in the ‘Assemblies to Document’ list box. 
  7. Document the assembly’s namespace by clicking on the ‘Namespaces’ button and editing the summary.
  8. The MyCompany.Common.shfb project is already configured so there’s no need to change any of the project properties. For future reference, all non-default values are highlighted in bold font within the property list. This information is most obvious if you toggle the project properties to display Alphabetically rather than Categorized.

    Here’s a list of the settings which have been updated:

    • Help Title=MyCompany.Common Class Library
    • HtmlHelpName=MyCompany.Common
    • KeepLogFile=False
    • OutputPath=./
    • PresentationStyle=vs2005
    • SdkLinkType=Index
  9. Generate the help file by clicking the Generate button in the toolbar.
  10. View the help file by double-clicking the MyCompany/common/MyCompany.Common.chm or by opening the file via the SCHB Documentation/View help file menu option.

Again, I found the tools easy to use though I did encounter one gotcha. My file path included a folder named ".NET 3.5".  I found that Help File Builder didn’t like the naming convention.  Apparently the preceding "." caused the issue.  Once I renamed the folder to "NET 3.5" everything worked like a charm.

 

kick it on DotNetKicks.com

References:


VS2008 Test Project Tips

04

August

As I mentioned last week, I am new to TDD.  For better or worse, all of my tests (and spikes) have been generated via Visual Studio Test Projects.  Working with VS Test Projects hasn’t been all that bad although I noticed a couple of annoyances right away. 

Is anyone else bothered by the fact that, by default, an unlimited number of test results and binaries are "deployed?"  If you are testing first, this arguably makes for a lot of useless activity and waste disk space.  Since the default TestResults folder location is set to be side-by-side with your solution files, the extra folders, trx files and binaries can also really interfere with your otherwise easy source control check-ins. 

Fortunately, there are ways to work around the excessive TestResults problem if you are running VS2008.  Some options are available through the IDE and other require an update to the .testrunconfig file directly:

Limit the number of deployed tests:

Tools > Options > Test Tools > Test Execution > Test Results Management > Limit number of old Test Results to the value of your choosing. 

The screen shot below sets the number of tests to one.  Therefore all previous tests are purged and only the latest test is maintained.

image

Disable Test Result deployment:

If you wish to disable the Test Result generation completely, double-click on your solution’s .testrunconfig file and uncheck the "Enable deployment" option.  No results will be generated thereafter.

image 

Change the Test Result folder location:

This option is hidden.  I don’t believe it is exposed in any of the VS 2008 dialogues and you have to edit the .testrunconfig file directly. 

Right-click on the .testrunconfig file > Open With… > XML Editor > Include the following within the TestRunConfiguration node:

<Deployment useDefaultDeploymentRoot="false" userDeploymentRoot="C:\TestResults" />

I hope it helps.

kick it on DotNetKicks.com

References:


Learning Test Driven Development

01

August

I am relatively new to the Test Driven Development (TDD) scene.  Though I have read up on the subject (specifically Test Driven: TDD and Acceptance TDD for Java Developers by Lasse Koskela), my only hands-on experience is limited to a single, 3-month project where I was the lone developer.  All other information gathered on the subject has been through blog entries, podcasts, ramblings and the occasional deCover Imagemo in the office.  Though I believe I have a good understanding of TDD methodologies, I am far from putting this, dare I say, knowledge to practice.  Good practice, that is…

A spike is a term associated with TDD.  A spike is nothing more than quick coding exercise which validates or invalidates an assumption.  Lasse Koskela says it more eloquently:

A spike is a short experiment with the purpose of familiarizing ourselves with the technology, tools, algorithms, and so forth, that we need for solving the problem at hand.  A spike is  a way to make an unknown known — at least to a point where we know whether it’s worth continuing to dig that way or whether we should start looking for another way.

If you are familiar with TDD concepts, you know that spikes offer no value with it comes to testability, maintainability, etc.  They are merely quick prototypes which I find immensely helpful but should not be considered the focal point of TDD.  Well, my first crack at TDD resulted in roughly 70% spikes and 30% actual tests.  Not too good.

There is no doubt in my mind that I always had the best intension to test-code-refactor, but I wasn’t yet familiar enough with TDD to know I was way off course. There was also no one around to put me on the right track (or keep me honest.) Putting my ego aside, I know I could have used some hand-holding when I was starting off with TDD.

Test Driven Development is a discipline.  Like many other disciplines, TDD requires a teacher, student and practice.  The teacher offers instruction and ensures the discipline is practiced correctly.  The good student gathers knowledge and implements under watchful guidance.  In my opinion, TDD is therefore a seemingly good fit for a team which embraces an Agile approach, collaboration, rapid development and testability.   I’m not saying the lone developer with no prior experience with TDD is not capable of learning TDD on their own. I know some are.  I know guys who have done it.  Simply, I am stating that TDD seems most accessible to the mentored developer working with team members who previously adopted the methodology.  To put it another way, I bet Test Driven Development concepts are best learned through practical, hands-on example.

I haven’t given up on TDD yet.  Who wants to hold my hand?

kick it on DotNetKicks.com


TortoiseSVN - Change User After Save Authentication

31

July

When you first access your SVN repository you are given the option to save your authentication information.   Nice feature, right?   Well, what if you need to access the repository via different credentials?  image

Here’s the trick:

  1. Right-click on the root folder
  2. Select TortoiseSVN
  3. Select Settings
  4. Navigated to Saved Data
  5. Clear the stored Authentication Data

The next time you need to access the repository, you will be prompted for your new credentials.


Analyzing Your .NET Code with NDepend

30

July

NDepend is a static analyzer that simplifies the management of a complex .NET code base. Architects and developers can analyze code structure, specify design rules, plan massive refactoring, do effective code reviews and compare different versions of the code. The result is better communication, improved quality, easier maintenance and faster development.  Sounds good, eh?

Full disclosure: I received a free pro version of the NDepend from Patrick Smacchia last week along with little encouragement to use the tool and buzz about it if I find it useful.  Patrick’s timing, in fact, could not have been better as just the evening before a colleague of mine was asking for code metric tool recommendations.  Hopefully the review represents me well, but I am thrilled with NDepend and recommend it highly to anyone wanting to get "more familiar" with their code.

As published by Patrick Smacchia

…something difficult in promoting a tool such as NDepend is to educate about what it can bring to your development shop in terms of agility. NDepend comes with a set of innovative features currently not supported by any other .NET tool. I like to think that what tools such as ReSharper or CodeRush are doing to your code at micro level (i.e methods’ body structuring), NDepend does it at macro level (i.e class, namespace, assembly structuring). Hence, as a developer I personally use both kind of tools to automatically control every aspects of the code base I am working on…

Being a big fan of ReSharper, I had high hopes for NDepend.  Knowing my co-worker could use some help finding a good code analyzer and having a free copy of the software dropped in my lap, I had the immediate incentive to dig into the NDepend tool kit…

How to Get Started

Since I wasn’t all too familiar with NDepend, I opted to first gather basic information about the tool and capabilities.  Here’s what I did:

1. I watched two online demos: Getting started and VisualNDepend basics

2. I reviewed three online tutorials: How do I analyze my .NET applications using NDepend?, What does the NDepend report tell me about my code? and I want to go further to have a better control over my code

3. I read a recent NDepend review posted by Andre Loker and previewed Patrick Smacchia’s Blog for his latest comments.

First Impressions

Before even opening the software it was very clear that NDepend was super powerful and, as another colleague of mine recently said, "it can be a mind blower."  As I am very sensitive to informatiimageon overload, I proceeded simply and cautiously by basically following the steps found in the online demos.  The Visual NDepend 2.9.0 IDE is friendly and somewhat familiar as the start page could be compared to that of Visual Studio.  Here you may create/open projects or analyze/compare assemblies using the provided shortcuts.  Additionally, you are presented with quick links to the online demos and the installers for NDepend Visual Studio and Reflector add-ins. 

imageI opted to analyze a set of assemblies.  After selecting a half dozen assemblies managed within my current application, the assembly analysis is run and then, after a few moments, the results are presented within the VisualNDepend UI. 

Remember my earlier comment about being sensitive to information overload?  Well, if I wasn’t ready for it, the tool’s default display may have knocked me off my seat.  As you can see in the accompanying screen shot, there are many views and the UI is quite busy.  For the experienced user this is great as the numerous windows actually work nicely together.  For a new user, in my opinion, the elaborate UI may be inappropriate — possibly intimidating — especially if the new user really only wants to gather a simple metric like how many lines of code (LOC) make up a specific component.

With this said, the UI can be customized and all the information is very useful once you understand it.  Don’t be intimidated by NDepend even though the first impression can be a "mind blower."

I clicked around the UI for about 30 minutes and I quickly got a good sense of its power.  Certainly the demos, tutorials and blogs noted above helped lessen my learning curve so I encourage you to follow my footsteps.

Code Query Language (CQL)

What impressed me most about the NDepend is its Code Query Language (CQL).  Per the NDepend site:

NDepend considers your code as a database and you can write some CQL statements to query and check some assertions on this database.

Out-of-the-box, NDepend comes with dozens of queries which fall into varying categories from Code Quality to Test Coverage .NET Framework Usage. 

And NDepend provides the same 82 code metrics to support you in building your own queries!   Here are a few simple examples of what you can do with the CQL:image

1. Which public methods have more than 30 lines of code?
SELECT METHODS WHERE NbLinesOfCode > 30 AND IsPublic

2. Which classes implement System.IDisposable?
SELECT TYPES WHERE IsClass AND Implements "System.IDisposable"

3. Which methods have been refactored recently and is not thoroughly covered by tests?
SELECT METHODS WHERE CodeWasChanged AND PercentageCoverage < 100

On top of that you can enable/disable or even edit the out-of-the-box queries.  For example, if you don’t agree that all static fields should be prefixed with an ’s_’ change the query to validate your standard or remove the check all together.

With the Code Query Language, the sky is the limit.  Did I mention the editor comes with Intellisense?

Reports

Go ahead and generate a report.  Check out this example which gives you a run down of the application and assembly metrics, an assembly dependency diagram, CQL Queries and Constraints and much more.  Whereas the VisualNDepend UI is geared toward the architect or lead developer type who is wanting to really dig into an application, the report seems to be more suitable for a less technical audience.  Perhaps the report could be used as part of an executive summary or could complement a developer’s code review.  Simply, it is a professional output (HTML only, I think) consisting of endless information and even pictures. 

Integration

Very quickly I wanted to call out that NDepend integrates not only with VisualStudio and Reflector but also MSBuild, NAnt, and CruiseControl.NET.  I personally think it is great that NDepend was implemented in a manner in which its frequent (read: continuous) and easy (read: automated) use is promoted.  Well done.

Final Thoughts

NDepend is darn impressive. It is a "mind blower" if you will.  NDepend provides more than ample metrics, a flexible (albeit busy) UI, a customizable query language, professional reports and hooks into applications like Visual Studio and Reflector along with support for processes like automated builds and continuous integration.  If you really want to know your code and you are looking for a tool which provides more than simple application metrics, NDepend may be the right product for you.  I highly suggest you check it out.

kick it on DotNetKicks.com


Introducing Lightning Talks

29

July

The folks I work with are wicked smart.  Go back and read that first sentence again.  This time read it like you are Ben Affleck in Good Will Hunting or one of the guys I used to play summer ball with outside of Boston. Fun right?  Anyway, the point is I work with really smart people and I like to push random characters voices into the heads of my readers. 

Tip Number 1: If you have the means, I suggest you plant yourself in a similar environment.  There’s nothing you can do to better for your career than surround yourself with talented, smart people who are passionate about their work.  It doesn’t matter if you are a junior coder, manager-type or CTO.  It’s just good sense.

The problem with my current environment is we are scattered amongst many projects, across many clients and the opportunity to collaborate doesn’t knock very often. We do have a weekly team meeting, but it generally focuses on business/management stuff.  I do find that software development talk often surfaces at lunch but arousing conversation around grass fed vs grain fed cattle is equally as likely.  There really was no venue to really talk shop and harness the collective software development knowledge of my coworkers. 

So, I suggested we start hosting Lightning Talks… The immediate response was very favorable (everybody likes to hear themselves talk, right?) and this week we held a very quick business/management team meeting and then the development staff started our first round of *modified* Lightning Talks.  I emphasis the word "modified" because we broke a rules.  Read on.  We kept things very informal and, in the spirit of lightning talks, intended to host a number of very quick quick 3-10 minute presentations.  Unfortunately, we kind of blew it with the time allotment as my two talks, one on AnkhSVN and the other on Inno Setup, took 5 minutes and then 45 minutes respectively.  All the same, everyone seemed genuinely interested in presentations and the pseudo-lightning talk concept (although you never know because I work not only with really smart people they are also very kind.)  Perhaps the best evidence of the Lightning Talk success was at least one coworker volunteered to do a presentation next week and our internal Wiki already has a section dedicated to presentation notes. 

Tip Number 2: Introduce a similar practice to your workplace.  No matter what you call the meeting, getting coworkers talking about technology is one of the best ways to get introduced to new ideas and sharpen your existing skills. 

Wish us luck on future talks.  Let’s hope my brain doesn’t get too big.

kick it on DotNetKicks.com


Getting Started with Inno Setup

28

July

For the first time in years, I needed to distribute my application to the end user’s machine via an online download.  To do this effectively and professionally, I, of course, needed an install package.  Over the year, I have used both Wise and InstallShield but they both cost money and I don’t recall them being all that easy to manage.  This was, however, years ago.  More recently I have, like many developers, used Windows Installer to imagegenerate MSIs for very simple (read: file copy) deployments. There’s nothing flexible or particularly pleasing about MSIs, but one can typically get them created with a few button clicks.  For the installation of internal applications, MSIs are more than tolerable, in my opinion.  Other than those options, I was quite ignorant on the subject of installers so I briefly evaluated three free candidates:

  • Windows Installer XML (WiX) Toolset is a Microsoft open source project used to create the Office 2007 installer. WiX includes some advanced capabilities, but it has a steep learning curve even though the scripting language is XML-based.
  • NSIS (Nullsoft Scriptable Install System) is a professional open source system to create Windows installers. It is designed to be as small and flexible as possible and is therefore very suitable for Internet distribution. It has a rich feature list, a good set of online samples and a good community following.
  • Inno Setup is another free, open source installer for Windows programs. First introduced in 1997, Inno Setup today rivals and even surpasses many commercial installers in feature set and stability.

Decision

After a quick review of each product, I opted to run with Inno Setup primarily because it had the ugliest website, all of their product award links are broken and it isn’t known by any acronym…yet.  Joking aside, I chose Jordan Russell’s Inno Setup because it met all of my requirements almost effortlessly.  Here’s the rundown of what I needed:

  • Check for the .NET Framework and install if not found
  • Check if Remote Registry is running and start if stopped.
  • Check is UAC is enabled and provide user dialogue.
  • Open website(s).
  • Create quick launch, desktop, start icons.
  • Read, update registry.
  • Ask custom questions and manage response.
  • Launch applications.
  • Install silently.
  • Create associated uninstaller.
  • Show/acknowledge terms of service.
  • Display readme.
  • Customizable/skinnable display.  
  • Etc

Additionally, Inno Setup it is such an easy tool to use and test and it has been around for a long while and has a great feature list:

  • Support for all versions of Windows in use today: Vista, XP, 2008, 2003, 2000, Me, 98, 95, and NT 4.0. (No service packs are required.)
  • Extensive support for installation of 64-bit applications on the 64-bit editions of Windows. Both the x64 and Itanium architectures are supported. (On the Itanium architecture, Service Pack 1 or later is required on Windows Server 2003 to install in 64-bit mode.)
  • Supports creation of a single EXE to install your program for easy online distribution. Disk spanning is also supported.
  • Standard Windows 2000/XP-style wizard interface.
  • Customizable setup types, e.g. Full, Minimal, Custom.
  • Complete uninstall capabilities.
  • Installation of files:
    Includes integrated support for "deflate", bzip2, and 7-Zip LZMA file compression. The installer has the ability to compare file version info, replace in-use files, use shared file counting, register DLL/OCX’s and type libraries, and install fonts.
  • Creation of shortcuts anywhere, including in the Start Menu and on the desktop.
  • Creation of registry and .INI entries.
  • Integrated Pascal scripting engine.
  • Support for multilingual installs.
  • Support for passworded and encrypted installs.
  • Silent install and uninstall.
  • Full source code is available (Borland Delphi 2.0-5.0).

Oh, and have I mentioned that it is free? 

Getting Started

The basic installer includes the Inno Setup Compiler, documentation and numerous samples.  If you want to get started quickly just download Inno Setup and review the sample scripts.  You’ll be creating your own installers in no time.  Alternatively, you could download/install the QuickStart Pack, but I honestly do not think it is necessary.image

As I mentioned, a review/compilation of the samples can provide a quick, easy introduction into the impressive tool. All the examples are worth a look, but I feel it is necessary to give a few special mention:

  • Example1.iss, Example2.iss and Example3.iss provide a great foundation as they demonstrate how to access the registry, add a desktop icon, include a readme file, etc, etc, etc.  
  • If you are planning to do anything non-standard, play around with the CodeExample1.iss sample.  It essentially builds a basic setup, captures every installer event, includes custom functions, and demonstrates how to extract/expand files, display dialogues and issue before and after installer actions. 
  • Finally, if you want to build custom pages, check out CodeDlg.iss which demonstrates how to build installer pages with custom questions and user input options.

My suggestion is to review the samples from within the Compiler.  The Compiler doesn’t have intellisense or anything, but it will obviously validate your script and call out where imageinvalid syntax exists.  The Compiler also allows you to immediately "run" your installer script (by clicking on the green arrow button) or compile the script (by clicking on the fourth button from the left.) What the heck is that anyway?  The Compile IDE is a fancy notepad with options and actions.  It’s simple and I dig it.

Speaking of simple, here’s an example script.  You would have to build on its foundation if you wanted to do anything fancy, like read from the registry, but these few lines practically do it all.  They copy three files into the Program Files sub directory, displays a read me file and add an icon to the Start Menu.  And all the standard installer pages (splash, location, completion, etc) comes along for free — free meaning no effort and no code.

[Setup]
AppName=My Program
AppVerName=My Program version 1.5
DefaultDirName={pf}\My Program
DefaultGroupName=My Program
UninstallDisplayIcon={app}\MyProg.exe
Compression=lzma
SolidCompression=yes
OutputDir=userdocs:Inno Setup Examples Output

[Files]
Source: "MyProg.exe"; DestDir: "{app}"
Source: "MyProg.chm"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"; Flags: isreadme

[Icons]
Name: "{group}\My Program"; Filename: "{app}\MyProg.exe"

Extra Help

Finding the right syntax wasn’t always a breeze as everything isn’t covered in the samples.  With that said, the best online reference I found was an Inno Setup Manual hosted at AgentSoft.com. I can’t say I know the connection between AgentSoft and Inno but I’m still very happy to have found the reference.  I also found various "real world" installer scripts, like this one, posted online which really helped facilitate my ramp up.

.NET Framework Install Script

In my requirements list, I called out the need to check for the .NET Framework and install if it wasn’t found.  This functionality is a snap using Inno Setup — just be sure to use the Client Profile version of the installer.

[Files]
Source: "Executables\dotnetfx35setup.exe"; DestDir: "{tmp}"; Flags: deleteafterinstall

[Run]
Filename: {tmp}\dotnetfx35setup.exe; Parameters: "/Q /NORESTART"; Check: Is35FrameworkInstalled; Flags: runhidden shellexec waituntilterminated; StatusMsg: "This may forever."

[Code]
function Is35FrameworkInstalled():Boolean;
begin
    Result := not RegKeyExists(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Microsoft\Net Framework Setup\NDP\v3.5′);
end;

Summary

I’ll keep it short and sweet: Inno Setup is one slick piece of software that made the dreaded task of creating a custom installer one heck of a lot easier than it could have been.  I’ve added Inno Setup to my toolbox and I highly suggest you do too.

kick it on DotNetKicks.com


Export GridView to Excel within an UpdatePanel

25

July

There’s a ton of information online about exporting a DataGrid or GridView to Excel, but most variations do not consider the GridView may reside within an UpdatePanel.  It goes without saying, but I was disappointed when I recently dusted off my “Export GridView to Excel” code snippet and encountered a number of exceptions.  So I revisited a number of links and I collected a working solution.  If you need a “simple” way to export your GridView to Excel and you are using an UpdatePanel, I hope the following code finds you well:

protected void btnExport_Click(object sender, EventArgs e)
{
    // Reference your own GridView here
    if (AccountGrid.Rows.Count > 65535)
    {
        DisplayError(“Export to Excel is not allowed” +
            “due to excessive number of rows.”);
        return;
    }

    string filename = String.Format(“Results_{0}_{1}.xls”,
        DateTime.Today.Month.ToString(), DateTime.Today.Year.ToString());

    Response.Clear();
    Response.AddHeader(“Content-Disposition”, “attachment;filename=” + filename);
    Response.Charset = “”;

    // SetCacheability doesn’t seem to make a difference (see update)
    Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);  

    Response.ContentType = “application/vnd.xls”;

    System.IO.StringWriter stringWriter = new System.IO.StringWriter();
    System.Web.UI.HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);

    // Replace all gridview controls with literals
    ClearControls(AccountGrid);

    // Throws exception: Control ‘ComputerGrid’ of type ‘GridView’
    // must be placed inside a form tag with runat=server.
    // ComputerGrid.RenderControl(htmlWrite);

    // Alternate to ComputerGrid.RenderControl above
    System.Web.UI.HtmlControls.HtmlForm form
        = new System.Web.UI.HtmlControls.HtmlForm();
    Controls.Add(form);
    form.Controls.Add(AccountGrid);
    form.RenderControl(htmlWriter);

    Response.Write(stringWriter.ToString());
    Response.End();
}

private void ClearControls(Control control)
{
    for (int i = control.Controls.Count - 1; i >= 0; i–)
    {
        ClearControls(control.Controls[i]);
    }

    if (!(control is TableCell))
    {
        if (control.GetType().GetProperty(“SelectedItem”) != null)
        {
            LiteralControl literal = new LiteralControl();
            control.Parent.Controls.Add(literal);
            try
            {
                literal.Text =
                    (string)control.GetType().GetProperty(“SelectedItem”).
                        GetValue(control, null);
            }
            catch
            {}
            control.Parent.Controls.Remove(control);
        }
        else if (control.GetType().GetProperty(“Text”) != null)
        {
            LiteralControl literal = new LiteralControl();
            control.Parent.Controls.Add(literal);
            literal.Text =
                (string)control.GetType().GetProperty(“Text”).
                    GetValue(control, null);
            control.Parent.Controls.Remove(control);
        }
    }
    return;
}
 

Update: 7/30/2008

I previously noted that SetCacheability doesn’t seem to make a difference.  Well, I was right…until I deployed my code to a site behind SSL.  As it turns out, in order for Internet Explorer to open documents in Office (or any out-of-process, ActiveX document server), Internet Explorer must save the file to the local cache directory and ask the associated application to load the file by using IPersistFile::Load.

http://support.microsoft.com/default.aspx?scid=KB;EN-US;q316431&

If the file is not stored to disk, this operation fails. When Internet Explorer communicates with a secure Web site through SSL, Internet Explorer enforces any no-cache request. If the header or headers are present, Internet Explorer does not cache the file. Consequently, Office cannot open the file.

RESOLUTION: Web sites that want to allow this type of operation should remove the no-cache header or headers. In other words, comment out the following line of code particularly if you are running under SSL:

Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache); 

Additional Comments

Per Jinath Blog, if you are using an UpdatePanel, you may get a System.WebForms.PageRequestManagerParserErrorException exception.  The solution is to add a PostBackTrigger and give it’s ControlID as the excel export button’s ID or you can move your excel export button out side of the update panel.  I verified both options and they work great.  I ultimately went with the former option as such:

    ...
    </ContentTemplate>
    <Triggers>
        <asp:PostBackTrigger ControlID=”btnExport” />
    </Triggers>
</asp:UpdatePanel>

Per ASPAlliance, you may encounter issues a number of issues which require the following solution.  Check out the link (and the comments) for more details if you get stuck.  I only encountered #1 on the list.

  1. You may get an exception which states your Control ‘Grid’ of type ‘GridView’ must be placed inside a form tag with runat=server.  I overcame this by dynamically adding a form to the page and then the GridView to the form before RenderContent().  This solution came per the aforementioned post’s comments.
  2. You may need to included the following page directive: EnableEventValidation=”false”.  I didn’t need to include this directive.
  3. You may need Override the VerifyRenderingInServerForm Method.  I didn’t need to do so because I added my GridView control to a “mocked” form.
     

Per Dipal Choksi, one can format the spreadsheet results in a generic manner by replacing all controls within the GridView with Literals.  This is reflected in the ClearControls() method above.  My prior implementation merely cleaned up the links associated with the sort functionality tied to the sortable headers.  This solution tackles all cells.

Additional Reference: GridViewGuy 

kick it on DotNetKicks.com


TSQL - Self Update

25

July

This morning I needed to compose a very simple SQL routine and it took me around five compiles until I got the syntax right.  All I needed to do was transfer an active status from one entity (in my case a computer) to another.  I decided to implement this by updating the same table in which I was selecting.  I think the syntax associated with "self update" type queries is tricky so this post is so I personally don’t loose this code snippet and future cycles.  I hope it might help you as well.

This example transfers the status of the source computer to the destination computer.  Nothing fancy…

DECLARE @SourceID INT; SET @SourceID = 2
DECLARE @DestinationID INT; SET @DestinationID = 1

DECLARE @Computer TABLE (ComputerID INT, StatusID INT)

INSERT INTO @Computer(ComputerID, StatusID)
SELECT @DestinationID, 1 UNION SELECT @SourceID, 2

SELECT * FROM @Computer

UPDATE A
SET A.StatusID = B.StatusID
FROM @Computer A, @Computer B
WHERE B.ComputerID = @SourceID
AND A.ComputerID = @DestinationID

SELECT * FROM @Computer

(2 row(s) affected)
ComputerID  StatusID
----------- -----------
1           1
2           2

(2 row(s) affected)

(1 row(s) affected)

ComputerID  StatusID
----------- -----------
1           2
2           2

(2 row(s) affected)

 

kick it on DotNetKicks.com


Getting Started with AnkhSVN

22

July

I’ve previously written about managing your Subversion repositories via the TortoiseSVN client.  TortoiseSVN integrates with Windows Explorer and provides a really slick way to do things like view the status of your source code, update your Subversion working copy and commit change.

But as slick as it is, TortoiseSVN requires one to bounce between their IDE and the Windows Explorer.  You’re right!  A simple, two-second step, a mere ALT-TAB, shouldn’t be that disruptive but, for me, it is and it keeps me from committing my changes as often as I probably should.  Perhaps this is a flaw in the way I work, but it is, without a doubt, the way I work.

There are two players in the "Subversion Source Control Provider for Visual Studio" space.  There’s VisualSVN and there’s AnkhSVN.   Until this week, I had heard nothing but good things about VisualSVN and AnkhSVN reviews weren’t nearly as favorable. 

I ended up trying VisualSVN for over a week and, frankly, I was disappointed. I deserve to get negative feedback about publishing the following comments without any supporting documentation but I found VisualSVN to be sluggish and I felt it called up TortoiseSVN dialogues (rather than handling the file management itself) far too often.  Since so many folks like the product, I would be willing to bet I simply had a very bad first go (although I did spend over 1 week with the product.) All the same, it is uninstalled, the $49 are still burning a hole in my pocket and, well, there was no harm done. 

I reverted to my old ways of not using source control effectively by avoiding Windows Explorer and TortoiseSVN and then, on my birthday, AnkhSVN 2.0 Final was released.  Though folks grumbled about the previous version, 2.0 is a near rewrite of the original and is now a full Source Control Provider Integration Package rather than a Visual Studio Add-In. With commercial backing from CollabNet and renewed open source enthusiasm, AnkhSVN 2.0 seemed to deserve a look so I looked…

Quick Start

1. Download AnkhSVN 2.0 here and run the install package.  If you want the latest and greatest, check out the daily builds

 

2. The AnkhSVN download page says to install and then "Start Visual Studio and choose Tools -> Settings -> Source Control and make sure AnkhSVN is the active source control provider."  Actually, you want Tools -> Options rather than Settings, but you would probably figure that out on your own.  All the same, AnkhSVN was already configured/selected.

 

3. Open an existing solution and noticed the new "Pending Changes" windows (also available via View -> Show Pending Changes.)  Enter your repository URL into the empty "Working on:" field and, if you are as lucky as me (after all it was my birthday), everything should just work. 

image 

 

4. This step is optional, but inevitable. I think. After about 20 minutes of playing with AnkhSVN you’re probably going to want to hook up your favorite diff tool.  If your favorite diff tool is WinMerge, perform the following: Go to Tools -> Options -> Source Control -> Subversion -> External Diff Path = "C:\Program Files\WinMerge\WinMergeU.exe" "%base" "%mine"

image 

 

5. Once you are setup, you will see green check-marks alongside items in the Solution Explorer window.  And, as you start to make changes, you will see modified items added to the Pending Changes window.  This, my friends, is  a great feature!  Now you able to manage all of your changes in a single location rather than having to navigate through Windows Explorer or even the Solution Explorer. In another life, StarTeam provided me with similar functionality by allowing me to flatten out the folder hierarchy and then sorting by status, but the Pending Changes windows is 100 times better.  Sure, you can manage your commits via the Solution Explorer, but I’m not going to. The Pending Changes view is also great since the Solution Explorer doesn’t always conveniently show you the status of your files.  Take the screen shot below, for example.  Collapsing the EmailTemplates folder leaves me no insight into the state of the files within.  (For the record, I prefer VisualSVN’s Solution Explorer display.)

 

image

 

 

 

 

Side note: If I could do it all over again, I really wish I followed the posted download instructions.  The suggested setup sounds straight forward enough, but trying to replicate the steps now, after already setting up, is seemingly impossible.  The instructions can be firmed up for clarity (see prior example referring to incorrect menu names), but I would have liked to give them a test run without jumping the gun and setting up my own way first.  If you do follow the published install instructions, let me know how it goes for you as I simply can not make heads or tails out of some of the steps.  One thing which seems to be missing — perhaps because of my impatience — is the persistence of the Subversion repositories added to the Repository Explorer.  It is really nice a version of the Repository Browser is built in, but it seems odd that repositories would need to be reestablished each time you open a solution.  Anyhow, it is probably my fault…

Wrap Up

Thus far, I am pleased with AnkhSVN.  For those of you who tried out earlier versions and were disappointed, try again.  Here’s a partial list of what’s new in AnkhSVN 2.0:

  • For Microsoft Visual Studio 2005 and 2008.
  • Built on Subversion 1.5.0 via SharpSvn.
  • Pending changes window; subversion status and commands available in one place
  • Full support for Visual Studio 2005 and 2008; AnkhSVN is now a SCC package instead of just an addin
  • Better log viewer
  • Merge support
  • Property editor
  • AnkhSVN now supports most project types previously unsupported via the SCC api
  • All solution explorer actions (rename, copy&paste, drag&drop) keep subversion history now
  • Enhanced build process and setup
  • Automatic check for updates
  • And last but certainly not least end user documentation

For more information about AnkhSVN, check out the project’s home.

kick it on DotNetKicks.com


Firefox Has Stopped Working…Again

09

July

I can’t possibly count the number of times the beautiful "Firefix has stopped working" message has popped up over the past two weeks. 

image

Sometimes, when the coding gods are smiling down on me, I am lucky enough to get the Restore Session / Start New Session prompt after I "Close program" and relaunch.  The majority of the time, however, I just keep getting the "Firefox has stopped working" message until I reboot my machine — a task I try to avoid in the middle of the work day.  I don’t know about you but I find it difficult to code when my computer is offline. 

image

As a result, IE became my default browser today because I simply do not have the time to debug the issue.  I’ll miss you firebug…


CONTACT

RSS

ARCHIVES

READ BY TOPIC

LINKS

LINK ADS