Category Archive.NET



.NET & Chillisoft & Databases & Microsoft 02 Jun 2009 03:04 pm

Microsoft SQL Server Reporting Services “Object reference not set” error

I had a system deployed to a client site, and everything was working perfectly. The system administrator at the client site did a few things on the server, and next thing the Reports in the web site that use Microsoft SQL Server Reporting Services were giving an error.

Nothing had changed that should have affected the site! So, what could be causing the error?

The error in the report viewer was: “Object reference not set to an instance of an object.”

That’s an all too familiar error to anyone that has programmed in .NET and it is always slightly amusing to find it in someone else’s released program. The other day I got one from SQL Server Administrator when I clicked on something in the tree view on the left (just after I had freshly installed Reporting Services). Aha, so they are not infallible! A slight grin etched itself across my face. Well, anyway, the solution was a tried and tested standard Windows solution… Restart the PC. Amazing how often that works with Microsoft stuff hey! But in my case I was getting the error in my application, in a section that I had no control over, so how could I save myself this embarrassment?
Continue Reading »

.NET 16 Oct 2008 10:16 am

Set Custom Password for MembershipUser

Perhaps I am missing something, but I couldn’t find a method on MembershipUser to set a user’s password to a custom one that I choose.  For instance, a common administrative practice when a user complains that they can’t remember their password is to set it to something like 12345 and get them to change it to something custom immediately after they log in.
Continue Reading »

.NET 20 Aug 2008 04:34 pm

Sorting a DataTable

When you’re starting out with DataTables in .Net, it might surprise you to know that you’re not able to sort the rows.  Apparently there’s a principle behind this, but when you’re in a position like I was where you’re constructing a complicated report that doesn’t obey the usual rules, then sometimes you need a DataTable that doesn’t obey the usual rules either.
Continue Reading »

.NET 15 Aug 2008 10:50 am

Solution File Corrupted: TeamCity Build Fails

We deal with a variety of build failures on TeamCity. When there is no obvious solution, you can try using “Enforce Clean Checkout”. You can also delete the checked out source on the build server. My error this time was:

“error MSB4051: Project {259E613F-1893-45D3-B0A7-6D778900C843} is referencing a project with GUID {8D503931-7BF0-4A4C-AA72-E9601719C9C3}, but a project with this GUID was not found in the .SLN file.”
Continue Reading »

.NET & ASP.Net & C# 01 Aug 2008 04:49 pm

Habanero and Visual WebGUI (VWG)

A few months ago we, were commissioned to undertake a project that required what most of us in the office cringe at, an ASP project, more specifically and ASP intranet project. So after some bad and tedious experiences with ASP just a few weeks earlier but still wanting to do this project, we scoured the interwebs for any tool that could some how help our interaction with ASP. We found what can only be described as a GOD-Sent, Visual WebGUI or VWG as its known. After spending some time using the VWG framework, testing it out and convincing ourselves that it met all our requirements, we made the monumental decision of reviewing our ORM architecture, Habanero, to see how easily we could fit the two together. The task seemed simple enough, all we really needed was to use the VWG controls instead of Windows controls. However after going down this route we decided that a more elegant soultion was required.

And so it began…
Continue Reading »

.NET & Web 18 Jul 2008 10:53 am

VevoCart Review: ASP.Net Shopping Cart

At the point of implementing a shopping cart, it becomes clear that writing your own is a lot of labour. From designing the front end, getting the tree heirarchy to work, integrating delivery, discount bundles, payment processing, order notification and managing speed of access, let alone the whole administrative backend, it makes sense to integrate a third party package.

We had a big problem though: our cart was no ordinary one. It had to integrate into an existing ASP.Net application and support a range of products that required extra logic.  We would also be using a local courier company (using web services) and payment handler.
Continue Reading »

.NET 23 May 2008 01:11 pm

Selecting Text when you Tab

I surprised to find out that .Net did not have an attribute that supports selecting the text of a field when you tab into it in win forms.  Either way, I implemented it by code and the solution to this problem looks something like this.  Feel free to modify/improve/extend/correct it.
Continue Reading »

.NET 12 Feb 2008 03:21 pm

DataGridViewCheckBoxColumn Stuck in Edit Mode

I ran into an annoying feature of the DataGridViewCheckBoxColumn today.  Having set up a DataGridView with a checkbox column, I needed to know every time the user clicked the checkbox, so that I could update a total at the bottom of the screen.  The catch is that as soon as they click on the cell, it goes into edit mode, so the CellValueChanged won’t pick up the click until they click on something else.
Continue Reading »

.NET 07 Jan 2008 10:14 am

No KeyPress in DataGridView?

While trying to detect a KeyPress event on my DataGridView, I began to suspect all was not well. Because deleting a row in an editable grid is not very easy for newbies (you have to click the side column first and then press delete), I was implementing a new improvement in Habanero where you can delete a row by pressing Delete while having a single cell selected (when not in edit mode). I was also including a similar option to clear the cell contents if you prefer, similar to Excel.
Continue Reading »

.NET & C# 03 Jan 2008 01:56 pm

Deleting Objects While Enumerating Through a Collection

In writing code where I was deleting the objects in a collection, I encountered the exception:

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

Simply put, I was using enumeration to walk through the collection, and the change in collection contents was messing up .Net’s counting system. My old code looked like the following:
Continue Reading »

.NET & Habanero 22 Oct 2007 07:10 am

Null Values for DateTimePicker

The .Net DateTimePicker is a stubborn animal. It does what it does and provides little leeway either side. There are three primary problems:

  • No time picker - I do like the editor you get when you double-click the clock in WindowsXP, but why not have something similar in .Net?
  • Non user friendly - when I was training users to use the picker to enter a date of birth, they took one look and went back to typing text
  • Not blankable

This last point now has a remedy in Habanero!
Continue Reading »

.NET & Philosophy 21 Aug 2007 04:36 am

On .Net Rocks - who wins the ORM Smackdown?

The ORM discussion seems to be a heated one in many circles, and in my attempts to market our new Habanero ORM product, I’ve run into the dialogue many times.

For those of you who don’t know about ORM - object relational mapping tools basically map relational database tables onto objects in code and vice versa. ORM tools are definitely on the up, because they automate a lot of work done to persist the data.

The full .Net Rocks interview can be found here: http://www.dotnetrocks.com/default.aspx?showNum=240. The discussion involves the inventor of the term “ORM is the Vietnam of computer science” (Ted) and one of the lead developers of Hibernate (Ayende), another ORM tool. Hmmm, interesting.
Continue Reading »

.NET & C# 08 Aug 2007 05:06 am

Casting Generic Types

Recently I was looking into generics and how to cast one generic type to another generic type of the same class. Just to make sure that you know what I’m saying, I’ll use an example:

Continue Reading »

.NET & C# 27 Jun 2007 11:14 am

Coding standards

If your company (or your internal monologue) is anything like ours (or mine), you’ll find yourself going back and forth between coding standards as people try different things and debate the merits of the varying positions of a curly brace. We had a sort of defacto set of standards that people mostly followed (helped significantly by the wondrous Resharper), but what has been helpful for us is to draw up a document that everyone is (mostly) happy with and simply stick to it.

As we were doing this we discovered a document by Lance Hunt entitled C# Coding Standards for .NET which did exactly what we wanted and more. A couple of the ideas in Lance’s document were different to ours, but for uniformity’s sake we have now officially adopted his standards. What is also useful in this document is coding style guidelines which can be checked against in code inspections. The superbness of Resharper allows us then to set the formatting standards up and save them to a file which we can then apply to all solutions.

The drawback is that office conversation and debate for the timebeing has been reduced to more mundane topics, like sports.