Object reference not set to an instance of an object

The infomous Object reference not set to an instance of an object error occurs when you try to reference or use an object that has not been set to a valid "value" or instance.  For example, let's assume you have a Class "Person" that has a property Name.  If you try to access the Name property and your Person object is not set to an instance, you will receive the Object reference not set to an instance of an object error.

In code:

Person p = null;
p.Name = "John Doe";

This is an obvious case, but what makes this error difficult to track down at times is when you do not know why you do not have an instance of the object.  This can occur for a variety of reasons.  If you are able to create a unit test (or already have one) this can help you to track down the root cause.  You can also rely on the stack trace and/or debug the offending code.

Create a self signed SSL Certificate

 The steps below ouline how to create a self signed cert for use on your local development machine.  This will allow you to run local sites under HTTPS for testing purposes.

1.       Bring up a Visual Studio Command Prompt:  “All Programs>Microsoft Visual Studio 2008>Visual Studio Tools>Visual Studio 2008 Command Prompt” (substitute "Visual Studio 2010" where appropriate if using Visual Studio 2010).

2.       Execute the “makecert” command for your machine.  For this example the fully qualified host name, “yourdomain.com
 
”, is used as the certificate name:
makecert -r -pe -n "CN=yourdomain.com" -b 01/01/2008 -e 01/01/2050 -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 yourdomain.com.cer

3.       Use the IIS Web Server Certificate Wizard by right clicking on the web site where you want to install the certificate.

4.       Steps to add the Certificate to the the website:

1.       Right click the the website.

2.       Select “Properties”.

3.       Select the “Directory Security” tab.

4.       Select “Server Certificate”  from the “Secure communications” section of the tab.

5.       Click “Next” on the intro to the Web Server Certificate Wizard.

6.       Check “Assign an existing certificate” and click “Next”.

7.       Select the certificate name you just created with “makecert” above and click “next”.

8.       Specify the SSL port.

9.       Review your selections and click “next”.

10.   Click “Finish” to end the wizard.


Client Certificate Installation

In order to use SSL without the warning/error messages that IE will display by default when the server’s SSL certificate has not been issued by a recognized Certificate Authority (such as Verisign, etc.); you will need to add the certificate created by makecert into the “Trusted Root Certification Authorities” store of your Local Computer.

The steps to do this are as follows:

1.      Open up mmc (type “mmc” at the run or command prompt).

2.       Select “File>Add Remove Snap-In…”

3.       Select “Certificates” from the “Available snap-ins” and click “Add”.

4.       Select the “Computer Account” radio button.

5.       Select “Local Computer”, then “Finish”, then “OK”.

6.       Open up the “Certificates>Trusted Root Certification Authorities>Certificates” branch.

7.       Right click on “Certificates” and select “All Tasks>Import…”

8.       Click “Next”

9.       Browse to the certificate file created by “makecert” and “open”.

10.   Click “Next”

11.   Click “Finish”

 

The full-text query parameter for fulltext query string is not valid

I started receiving the error the full-text query parameter for fulltext query string is not valid after upgrading to .NET 4 when calling a function in SQL Server 2008 from Linq to SQL.   It seems LTS is sending the string as nvarchar(4000) event though I had defined the paramater to the function with a length of nvarchar(200).

The work around that I put in place as we define the parameter to my function as 4000.  Not ideal, but it resolved the error.

Delete not working with LinqDataSource

Recently I was working on a custom page in a Dynamic Data project and the "Delete" link was not working on a GridView that had a LinqDataSource as its data source.  Below are the steps I followed to resolve:

First, I was getting an error when clicking delete for a record in the GridView

LinqDataSource 'GridDataSource' does not support the Delete operation unless EnableDelete is true.' when calling method

This was fixed easily by setting EnableDelete="true" on the LinqDataSource.

Next up, I needed to set the DataKeyNames on the GridView.  This basically indicates what the where condition will be for the delete operation.  I set the GridView DataKeyNames equal to the name of the primary key column in my table.

That will probabaly resolve for most people, but for me, it did not.  I had also set the Select property on the LinqDataSource and this was preventing the delete from occuring.  Once I REMOVED the value for this propery, all worked.

The below article was helpful in diagnosing:

http://msdn.microsoft.com/en-us/library/bb514963.aspx

 

Software Development Podcasts

Below is a list of software development podcasts, IT Podcasts, and general computer related podcasts. Please add commnets on podcasts you enjoy...

.NET Rocks - This is a really good (quality and content) podcast that focuses on .NET development.  While the main focus is .NET there is a fair amount of content that applies to general computing and development such as design patterns, agilie practices, and more.

Software Engineerig Radio - This podcast provides an excellent variaty of topics that span technologies, languages, platforms, methodologies, etc. The shows can be rather technical and geared more toward knowledgable developers, but still offer a wealth of knowledge for beginners through experts.

Hansel Minutes - This is a weekly podcast that is primarily focused on Microsoft technologies but also includes other technologies and topics from time to time (for example digital photography).  While Scott is a Microsoft employee, the cast is rather open to non MS technologies and techniques such as TDD, ALT.NET, etc.

The Java Posse - This is an excellent podcast focused on the Java language, platform, and related technologies.  It provides both technical information as well as news and events within the Java community.

Buzz Out Loud - This is a daily podcast that is a summary of news and events relating to technology.  The personalities of the hosts really help to seperate this podcast from the usually news recap type shows...certainly worth checking out...

Polymorphic Podcast - A good podcast focusing on development and .NET.  The podcasts sometimes include screencasts and overall provides a lot of good content.

SSWUG - A database centric podcast dealing mainly with SQL Server but does include topics on other RBDMS as general database best practices.

Slashdot Review -  While at times biased, this can be a quick and informative cast.

Google Developer Podcast - Hopefully this will be a good resource to learn more about the technolgy offerings available through google.

Windows Weekly Podcast - Interesting take on the windows world.

ALT.NET Podcasts - A really good podcast that covers topics that all developrs should familiarize themselves with.

Deep Fried Bytes Podcast - Good podcast focusing on mainly Microsoft development

Thirsty Developer - Another good developer podcast focusing mainly on .NET

herdingcode.com - Good podcast relating to development

WebDevRadio - Covers web development

eCorner - Stanford entreprenure podcast 

Stackoverflow - development podcast 

ThoughtWorks - Business and technology topics

Agile Toolkit - topics relating to Agile development 

Udi Dahan - SOA podcast 

Endpoint.tv - New show hosted by Ron Jacobs on REST, SOA, web services, etc. 

http://pixel8.infragistics.com/default.aspx - UI, UX, RIA info

Finacial Physician

Railscast - webcasts on Ruby on Rails

Rails Podcast - podcasts on RoR

FLOSS - Weekly podcast on free and open source software

GiaOM - weekly show about technology and business 

Pragmatic Programmers - Interesting tech podcasts

Rails Envy - Regular podcast on Ruby on Rails

The Start Up Success Podcast - Name says it all...

This Week in Start Ups - Podcast on business and technology

Mobil Orchard - iPhone development topics

Stuff You Should Know - Variety of interesting topics from science to general knowledge....quite entertaining....

 

 

Silverlight Alpha C# Silverlight project issues VS 2008

Using the VS2008 Beta 2 VPC, I have encountoured an issue that results in your HTML files not loading your silverlight controls.  I am not sure what the root cause is, but my work around was to delete the html, js, and xaml files that are created when you create a new project and then add new ones.  Once I did this I was able to see the silverlight controls I had created in my xaml files.  Keep in mind that you will need to add all of the "wiring" code to your new files, which includes your reference to the js files and the div's to load your controls, etc.