Things I’d like in an IDE

I wish Resharper had a feature which pointed out where exceptions are being created but aren’t being thrown (ie, new Exception() instead of throw new Exception()). I also wanted a feature which automatically sets breakpoints where exceptions are thrown, although after thinking about that for a bit I’m not sure about that. I do really like the syntax checking for the most part, even if it messes up sometimes. And I still do go back to Emacs for anything repetitive; I haven’t seen anything in Resharper or VS that allows for Emacs-like macros.

Reducing the Size of SQL Server Log Files

I just ran into a problem where we were not able to create new tables in the database.  The CREATE TABLE command would simply hang.  After examining the log files, we saw the following error:

“Autogrow of file ‘<database_name>_log’ in database ‘<database_name>’ was cancelled by user or timed out after … ”

I examined the log files and found that the log file for the database had grown to over 50Gb.

My first attempt to truncate the log file was to use the “Shrink file” option from within Microsoft SQL Server Management Studio.  To get there, right-click on the database name, select “Tasks” -> “Shrink” -> “Files”.  In the dialog box that appears, change the file type from “Data” to “Log”.  I tried several time to shrink the log file this way.  No luck.  I was not able to reduce the size of the log size to less than its allocated 50Gb.

The solution that my co-worker and I found was to use some SQL statements to reduce the log file size.  The SQL we used was as follows: Continue reading Reducing the Size of SQL Server Log Files

GetType() Vs. Is

I wrote two functions and disassembled them using Reflector:

.method private hidebysig static bool CompareWithIs(class ConsoleApplication1.A x) cil managed
.maxstack 2
.locals init ([0] bool flag)
L_0000: nop
L_0001: ldarg.0
L_0002: isinst ConsoleApplication1.B
L_0007: ldnull
L_0008: cgt.un
L_000a: stloc.0
L_000b: br.s L_000d
L_000d: ldloc.0
L_000e: ret
private static bool CompareWithIs(A x)
return (x is B);

BlackBerry Simulator – *.debug File Not Found

I encountered an interesting (and frustrating issue) with the BlackBerry simulator in Eclipse. I got an error upon starting the simulator that the *.debug file was not found with some options to search and browse for it. Looking around my system showed that indeed – no *.debug files exist. I’ve tried many things, erasing all my Simulator Files, cleaning the build, re-building and so on, to nothing helped. Eventually I ran into this forum threadin the blackberry forums discussing this specific problem. It turns out that sometime, even though there are errors in the build – no errors will be shown, making you believe the build was successful. However, this is not the case. There should be an *.err file (were the *.debug file should have been) describing a compilation error in code.

Seeing that this came from the same error mentioned in the thread – _X is not Persistable: base Class does not implement net.rim.vm.Persistable_ , it might be that this specific error has a problem displaying in Eclipse.

Economy of the Cloud

Ed Felten at Freedom to Tinker recently posted an article about the economics of cloud computing (partially in response to last week’s New York Times op-ed about the cloud). While I agree with Felten’s main contention – namely, that the cost of resource management is a driving force in the movement towards the cloud – I would argue that there are also much more important factors at play.

Within the last few years, startups and small companies have seen a growing focus on web- or phone-based applications, from which customers expect much higher uptime, performance, and reliability. Even beyond the cost factor, there’s no real reason for a small company to grow their own servers* when alternatives exist with much better guarantees of all three of those expectations. This is particularly true near the start of an application life cycle, when the amount of data required to run effectively is often disproportionate to the size of the actual user base – if a small company were to run their own servers, they would have to endure remarkably low resource utilization. But even with established applications, it makes much more sense from a practical standpoint not to waste CPU cycles during low traffic times of the day or year. So ultimately I see the movement to the cloud as being spawned mostly from four separate factors:

  • The desire for greater reliability
  • The fact that most companies would prefer to focus on their primary objective (e.g. developing software) rather than working on supportive infrastructure Continue reading Economy of the Cloud

Reducing the Length of XML Data Returned from a Web Service

I’m working on a project for a large consulting customer.  The application we’re developing has a SOA that uses WCF services to return data.  A requirement is that the data be communicated using XML for maximum interoperability between potential heterogenous (Microsoft and non-Microsoft) environments.

The problem I’ve run into is that some of the data sets can be quite large.  We’re using the built-in functionality of the ASP.NET DatSet object to serialize the data and table schema information to XML.  This is very fast and convenient to code, but the generated XML is very verbose and adds a lot of overhead.  This resulted in errors in clients of the web service with the message “The maximum message size quota for incoming messages (n) has been exceeded“.  I increased the MaxReceivedMessageSize property on the binding in the web.config file to 50000000 (yes, that’s 50Mb), but I still ran into the same error.  I really didn’t want to keep increasing the max message size and be sending 50Mb, or even more, of XML across the wire.  Continue reading Reducing the Length of XML Data Returned from a Web Service

Debugging XAML and Prism

The biggest frustration in my Silverlight development is debugging errors in my XAML code.  Since our app uses Prism, there are often three different .xaml files involved in any one change to the app: App.xaml for global styles, Shell.xaml for the main layout and a .xaml file for whatever view I’m working on.  If something goes wrong, knowing what file it’s in is half the battle.

Unfortunately, the errors that Silverlight throws when you have malformed XAML can be pretty obtuse.  Through trial, error and a little intuition I’ve figured out that there are some patterns:

  • If nothing at all renders, the problem is likely in App.xaml.  That gets loaded first, and if something goes wrong then you get bupkus.  Check for syntax errors in App.xaml.
  • If the only thing that renders is the spinny loady thing (I actually don’t know if this is a Silverlight default or a StockTraderRI thing) then I think that usually means the problem is in Shell.xaml.  App.xaml has loaded at this point, but something is keeping the rest of it from going.  Often this can happen if you’re referencing something in App.xaml that’s syntactically valid but semantically nonsense.  Check especially for mis-spelled values inside Setter tags, or badly structured ContentTemplates. Continue reading Debugging XAML and Prism

Importing CSV Data into SQL Server

On a fairly regular basis at work I have to take .csv files with data from a customer’s database and import them into my SQL Server instance. This should be a simple operation, but the design of the native SQL Server Data Import tool makes it much, much more complicated than it needs to be. The biggest pain point by far is having to specify the data types of every single column in the data source by hand. Not only does it assume that everything is a string, forcing me to go through and figure out which types are a date, an int, a float or whatever else I have in the database, but by default changing a column’s type to a decimal uses decimal(18,0), truncating all my floating point values.

It always seemed a bit absurd that I should have to manually specify the types of all my data since I was importing into a database where the data types of the columns are explicitly specified. Once the import tool knew what table I was importing into, shouldn’t it be able to figure out the types for me?

So I wrote a Python script to import data for me. It uses the pymssql module to connect to the database, and the main insert function requires only three arguments: a connection to a database, the name of the table to import into, and an object with a function to return the names of the columns and then be able to iterate over the data. Conveniently, I also wrote a CSVFile class that wraps around a .csv file and provides just that functionality. Continue reading Importing CSV Data into SQL Server’s Jonathan Spink Reviews OfficeWriter for SQL Server Reporting Services

The following is an excerpt from’s Jonathan Spink as he reviews OfficeWriter’s integration with SQL Server Reporting Services (SSRS). Read the full review here.

“…The idea behind OfficeWriter is to extend the functionality of software users are already familiar with, i.e. Excel and Word, so they’re able to both acquire the data they need and arrange it into a useful form. While OfficeWriter does come in two more specific forms, ExcelWriter and WordWriter, this review looks at the version developed for use with SQL Server Reporting Services (SSRS), available in both 2000 and 2005 incarnations.

In order to take advantage of the different parts of this system, the OfficeWriter for SSRS package comes in two parts. The Designer is what you use to create the reports, either in Excel or Word, while the Renderer sits on the Reporting Services server.

This then is the OfficeWriter approach: from the Ms Office front-end, reports are produced in the SSRS XML-based RDL format, then uploaded to the SSRS ReportServer database, like any report produced using Visual Studio (VS). This means that they can also be viewed in Report Manager along with any other SSRS reports you have.”

[Read the full review]