Category Archives: Programming

Troubleshooting Tools to Give Thanks to this Thanksgiving

thanskgiving

[Once a week I snoop around the office, bothering my coworkers with questions on what they’re reading, listening to, consuming, or any other random inquiries I’d like to subject them to. Sometimes they even respond.]

Debug, de-stress. This week we’re giving thanks to these troubleshooting tools that keep us sane. We chose troubleshooting tools not for the alliteration value (though, that was a happy coincidence), but to find time-saving ways you can stay on top of your coding projects this holiday season. See below as we show our appreciation for developer tools we can’t live without. What other tools do you use to debug and de-stress? Tell us about them in the comments section below.

Chad, Sr. Sales Engineer

Fiddler2 helps make debugging web service calls easy.

Paula, Director of HR

Don’t even need to think about that one – System Restore Manager!

Ozgur, Development

I’d definitely list Fiddler and WireShark as some of the top troubleshooting tools that I am thankful for.

Aviva, VP of Technical Services

I mostly use the debugger in Visual Studio or custom code I write myself. Although it’s not a development tool, Procmon can be helpful, for monitoring activities on the filesystem and registry.

Stephanie, Technical Services

Total Commander is great. The program does a ton of stuff, but I really like its Continue reading Troubleshooting Tools to Give Thanks to this Thanksgiving

Thinking Outside the Spreadsheet Box: Unexpected Uses of OfficeWriter

If you leave me alone for too long, I do foolish things like make a mini-paint app that writes the image to 1×1 cells in Excel. And so can you! But before I show you how to make a mini-paint app (the easiest thing you will ever do in your life), let me explain to you what part of me said, “Yeah, Champ, this is a great idea! Who wouldn’t want to make a weird spreadsheet that contains an image made with the background color on cells?” It all began when I was thinking about this awesome idea by my art crush, Evan Roth (*swoon*). He said, “Hey world! I want work to be art,” and decided to make a double-mouse that outputs to an art program on one screen and his regular work on the other. So I figured, why not put some art in Excel too?

Then I got more and more excited as I realized there are actually a ton of cool things you can do…

  • Use the formulas in Excel as transformations on your picture.
  • Randomize cell size to introduce weirdness.
  • Flip the project to input an Excel template and output an image, using Excel calculations and System.Draw to make a simple ray tracer.
  • Do some stuff with conditional formats, or all those light transform equations you learned in high school for no reason…until now!
  • Make a mock tool that lets users draw a spreadsheet design and output it to a real spreadsheet! (I thought a lot about this, and it’s not necessarily simple, but it is a really cool idea. If anyone puts that together, please let me know. I mean you, Evan Roth….Call me?)

The Mini-Paint

For the sake of simplicity, I’m showing you the randomized cell idea. I’ve made it an optional setting in this example, but, you know, make it your own and all. Oh, also, get at me with your art! For this app you’ll need WinForms and OfficeWriter.

appwindow

I started by making a pretty basic app that has some simple actions. The “canvas” is a PictureBox that I save and resave some drawing objects to on each mouse event. The color selector is just 8 flat buttons set to be the color they represent. The shapes are again flat buttons with Wingdings images because I was too lazy to find a relevant .res file with some neat picture icons. Can you guess what the size toggles are? Flat buttons. Generic plus/minus from your plain boring keyboard. Okay. Basic functions.

  • MouseDown sets a pointer location.
  • MouseUp nullifies the pointer location.
  • MouseMoved is a basic drawing function. (You can find a ton of examples, but I like this one from good ol’ SO.)
  • Color buttons set a global variable, _selectedColor, to the color of the button.
  • Shape button clicks set a global variable called _selectedShape. I set it to an enum of possible shape options and I use a switch statement in the draw method. Instead of calling DrawLine or DrawRectangle, I call DrawShape(x,y) with x and y being current mouse x and y.

DrawShape is roughly this: Continue reading Thinking Outside the Spreadsheet Box: Unexpected Uses of OfficeWriter

5 Ways to Make Programming Less of a Nightmare

Credit: HubSpot

Programming can be scary.  There are plenty of things that can go wrong, from haunting errors to seemingly supernatural result inconsistencies.   To help keep the ghosts in the machine from getting the best of you, here are some tips my co-workers and I have picked up over the years.

 

 1)  Make a rough draft

Just like writing a paper, programming requires some forethought.  When you’re given a new programming problem it is always tempting to start coding right away, especially if you are in a rush.  However, taking the time to make an outline of your program first will save you lots of headaches later.  Even if it is a seemingly simple problem, think about what methods and helper methods you are going to need, what variables they will take, and how they will interact.  It is generally easier to debug code errors than logic errors, so work out the logic as much as possible before starting to code.

2) Listen to music

Having also tried TV, audio books, and silence, the best way I have found to stay productive while coding is to listen to some upbeat music.  It seems I am not alone in this opinion, as the internet has many playlists labeled specifically for programming. (In fact, we have a few of our own you might like.)  Music drowns out background noise but can easily be tuned out, keeping you focused and helping the time go faster.  So to prepare for your next coding marathon just put on your headphones.  Before you know it you will be halfway through your code and typing in beat to the music.      Continue reading 5 Ways to Make Programming Less of a Nightmare

Boston Tech Events: Idea Week, Breakfast with VCs, and You

Boston Seaport
Credit: Elise Kovi’s Flickr

Another Monday, another work week. Unlike every other Monday, however, today ushers in the month of October and with it Boston’s Idea Week. Reawaken your inspiration, and herald in the new month with this entrepreneurial-centered event, taking place in the Seaport’s Innovation District. Plus, check out a handful of other tech-related events geared toward entrepreneurs, start-ups, and the generally curious. So get out-and-about the city, meet your next VC or co-founder, explore new ideas, welcome the change in season, and add these Boston events to your calendar.

Boston’s Idea Week

When: Oct 1-10

Where: Innovation District – at the Seaport

Details: Each day a new activity. Aimed at furthering the growth of Boston’s Innovation District, this week-long event is working “to bring together Boston’s change-makers, leaders, creative thinkers, entrepreneurs and world-class college students to share and celebrate innovative ideas, products, networks and businesses that are being tested and formed in Boston.”

http://www.bostonideaweek.org/

Twitter: #IdeaWk13 @BosIdeaWk

Boston Tech Breakfast Meetup

When: Oct 1

Where: Microsoft New England Research & Development (NERD) Center

Details: Who doesn’t love breakfast? Made for techies, developers, designers, and entrepreneurs, this meetup is true to its namesake. Over a bagel and coffee, share in the monthly show-and-tell format of presentations by local start-ups. Contact them for the opportunity to showcase your company.

RSVP: http://www.meetup.com/Boston-TechBreakfast/events/128096822/

Hacks Hackers Boston Meetup

When: Oct 16

Where: The Boston Globe – 135 Morrissey Blvd., Dorchester, MA

Details: Three Nieman fellows will “discuss the growth and impact of digital and social media in Latin America, India, China—how users are employing technology to report and comment on the news, organize and motivate civic groups, and circumvent government controls.”

Speakers: Leslie Hook, Beijing correspondent for the Financial Times; Hasit Shah, senior broadcast journalist at BBC News in London; Daniel Eilemberg, founder and editor-in-chief of Animal Político

RSVP: http://www.meetup.com/hackshackersboston/events/140537532/

Continue reading Boston Tech Events: Idea Week, Breakfast with VCs, and You

How to Render an SSRS Report Asynchronously using the Async\Await Keywords in C# 5.0 with .NET 4.5

The .NET Framework 4.5 introduced a simplified approach to the task-based asynchronous programming model (which was introduced as part of the Task Parallel Library API in .NET 4.0) via the utilization of the two new keywords:  “async” and “await” in C# (Async and Await in VB.NET). For detailed information, see Asynchronous Programming with Async and Await (C# and Visual Basic)  on MSDN.

In this post, I’d like to show you how we could use these new keywords when making asynchronous calls to the SQL Server Reporting Services web service.  For the purpose of simplicity, I created a very simple Windows Forms project in Visual Studio 2012 in which I just have one button which invokes the SSRS web service in the click event handler.

First we need to make sure the target framework for the project is set to .NET 4.5 in Visual Studio 2012 (from the project properties).

Then we add a service reference to the SSRS web service. This part is a little tricky.  In the “Add Service Reference” dialog, after we put in the URL of the ReportExecution2005.asmx file of the Reporting Services into the Address box and locate the service, in the “Services” panel it should list the “ReportExecutionService” and if you expand that, it would show the “ReportExecutionServiceSoap” underneath. Here we select the Soap service. Then, after specifying a namespace for our reference (I just named it as “SSRSWebService”), we click on the “Advanced” button at the bottom which opens the “Service Reference Settings” dialog (as seen in the screenshots). In this latter dialog, we will make sure the “Allow generation of asynchronous operations” is checked and the “Generate task-based operations” option is selected. What this does is that Visual Studio will generate the async methods for the SOAP proxy class by using the Task<> return types.  Then we click “OK” and close the dialog.

HowtorenderSSRSreport_image1 HowtorenderSSRSreport_image2

Here I would like to underline one key part. In the second step we added the reference to the SSRS web service as a “service reference” (just like a WCF service), not as the legacy web reference (which was the old way of adding web service references prior to .NET 3.5 and WCF).  One other thing I want to point out is that here I am using the ReportExecutionServiceSoapClient proxy class, not the ReportExecutionService class which would have been the case had I added the ASMX reference as a legacy web reference. The interfaces exposed by SSRS differ slightly (different method signatures and different members) between when it is added as a WCF service (in this case it is the SoapClient) versus a legacy web reference.  Since my goal is to use the new .NET 4.5 features, I had to create the service reference in the new WCF way.

In my WinForms project I render the report located at the /MyReports/Report1 directory in SSRS as a PDF file. Here is the code for the button’s click event handler: Continue reading How to Render an SSRS Report Asynchronously using the Async\Await Keywords in C# 5.0 with .NET 4.5

Windows 8.1 Hyper-V in Review

Credit: TechRadar.com

[Reposted from www.nicolascouraud.com]

Working with developers, I have a love of client-side virtual environments. They allow for snapshots, easy portability of the development environment, and simple and unobtrusive replacement if and when someone blows up their development workstation. When Microsoft announced they were adding client-side Hyper-V in Windows 8, I had high hopes. However, the Windows 8 RTM release of client-side Hyper-V left a lot to be desired from a client-facing solution. It was merely a port of the server-side experience to the client. While it works well for me (I tend to run everything over RDP anyways), for our developers, lack of basic functionality like copy-paste or dynamic window sizing made it DOA.

Thankfully, in the Windows 8.1 (Blue) release, many of these shortcomings have been rectified! The virtual machine connection windows have been redone using the remote desktop engine which means that all of the features you didn’t have before (sound, 3D graphics acceleration, copy-paste), are now available without any workarounds. The full list of features supported in this enhanced session mode are: Continue reading Windows 8.1 Hyper-V in Review

Binding bordered images to GridViews

Here’s a neat trick: bind an image with a border to a GridView!
The first rule of web development is “nothing is as easy as it seems.” I think the second rule is something about choosing from standards? I don’t really care. The point is, this seemed like it would be too easy, but the implementation threw some curves at me. Let’s hearken back to a simpler time and begin our journey with a list of possible horrors:

  • The image object links to a physical location. It does not write BLOB objects. Friggen nothing writes BLOB objects.
  • Sometimes there are null values.
  • I need a border. This will create a little empty black square if a null is encountered.
  • What the heck is the difference between <%# and <%= again? And how the heck do I search for it? (Look here for explanation and links. Please read this. You’ll be so happy you did.)

Now we follow our hero on her continued path of – yes, hero is the male form. Don’t judge me. You don’t know – discovery. The first step is, of course, to point the Image object to an HttpHandler and pass that the ID for the data row containing the image. The handler itself is a pretty straightforward interface. There’s only one method: ProcessRequest() where you need to implement a method to grab the data from SQL. There’s also one property:  good ol’ IsReusable(). IsReusable is a boolean value that indicates whether or not the HttpHandler object can be reused. There’s a lot to take into consideration here:

  • Threading
    • If you have multiple threads accessing this at the same time you can completely screw up the state. What I’m doing is getting the query string within the process request. This is fine since the variable is local to the method it will be unique to the thread. You don’t have to stick to my code, though. If you are reusing the object, remember that any thread can, at any time, be changing a global variable.
  • End state of the handler
    • This is especially important here, since we’re using a lot of data objects, we need to make sure everything is properly disposed before the method is done executing.
  • Memory considerations
    • If IsReusable is false, then a new handler will be created for each request. This can cause performance issues if you have a lot of, say, users, accessing this, say, all at once. However, a simple httphandler doesn’t usually cause a lot of memory bloat. This is one of those application-specific things.

Whether you set IsReusable to true or false really comes down to what you need this handler to do. If you’re really uncertain, leave it at false – it will at least guarantee there are no multithreading nightmares, like in the sopranos. Continue reading Binding bordered images to GridViews

What Causes Error 1154 in WiX

Credit: www.joyofsetup.com

Recently, as I was working on one of our installers, I had a very strange issue crop up. This particular installer is fairly complicated, but also fairly stable.  It has many managed custom actions, and I was merely adding some functionality to it. I was testing the installer and ran into an 1154 error:

“There is a problem with this Windows Installer package. A DLL required for this install to complete could not be run.“

That’s fine. This happens. It’s pretty common, actually.

  • Check the names in the custom action declaration.  Do they match the DLL and method name, including case?
  • Are you trying to run a 64bit DLL using a 32bit installer?
  • Are you running MakeSfxCA.exe correctly with the most recent version of the DLL and installer?
  • Does the method you’re trying to call have the correct signature?

[CustomAction]Public static ActionResult MyCustomAction(Session session){….}

In this case, my problem action was, let’s say, HereIsMyCA. I checked through all of the above items several times. Most confusing was that other custom actions from the same DLL worked just fine. One might say I was getting a bit frustrated.  Eventually, I changed the name of the action and method – ThisIsAwfulPleaseWork.

…and it did.

After some experimentation I discovered that the problem lay in the capitalization of the C# method.  HereIsMyCA was breaking, but HereIsMyCa was fine. Most other methods with similar capitalization (several capitals in a row) worked fine. I’ve had one other method break. There is no rhyme or reason to it, but I hope that I save someone some hours with my discovery.

Boston April Meetups: What to do for the Tech-Savvy Entrepreneur in You

Credit: www.NewEnglandMagazine.comThe sun is finally peeking through the gray skies of Boston, beckoning Bostonians to emerge from their wintery confines and bebop around the city. Thusly, I set out to find a few meetups for the tech-savvy entrepreneur in you to explore this April. (Disclaimer: I have a bit of a love affair with the New England Research & Development Center here in Cambridge, so forgive me if the recommendations are a bit NERD-centric.)

  1. MozPub Mondays
    1. When: April 1st, 7pm (and every Monday in April thereafter)
    2. Where: Grendels Den, 89 Winthrop St., Cambridge, MA 02138
    3. Description: Connect with other web dev aficionados over a pint for casual discussions on bringing the world of Mozilla to Beantown. First one happens tonight! Don’t miss out.
  2. Dispute Impossible: Build and Run Applications that Bring the Enterprise Together
    1. When: April 17th, 9am – 1pm
    2. Where: Microsoft NERD Center, One Memorial Dr., Cambridge, MA 02142
    3. Description: Microsoft, K2, and Atrion plan to show you how to bridge the disparate systems and applications of the enterprise. In this session they will show you how to build and integrate applications across the departments in your company.
  3. Clash of the Clouds: Azure vs. Open Source Cloud Services
    1. When: April 30th, 6:30pm – 8:30pm
    2. Where: Microsoft NERD Center, One Memorial Dr., Cambridge, MA 02142
    3. Description: Bring on the debate. Not your traditional session style, this meetup Continue reading Boston April Meetups: What to do for the Tech-Savvy Entrepreneur in You