Windows Forms DataGridView Formatting

Time Formatting

To format Null set the Null Value in designer, or code for empty string.

Found when binding to a POCO class with TimeSpan that had some errors with some formats. hh\:mm seems to work.

To format 00:00 as blank then:

    Private Sub TimeDataGridView_CellFormatting(sender As System.Object, e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles TimeDataGridView.CellFormatting

        If e.ColumnIndex <> myColumn.Index Then
            Exit Sub
        End If
        If e.Value = New TimeSpan(0, 0, 0) Then
            e.Value = ""
            e.FormattingApplied = True
        End If

    End Sub



This is well documented elsewhere. The purpose of this post is to collate links and pull out for my own notes those features and commands that I most use, and may not recall.

NuGet Package Manager Console

Finding and Installing a NuGet Package Using the Package Manager Console and removing and updating a package

Key commands:

  1. get-help Install-Package
  2. Install-Package EntityFramework
  3. Unistall-Package EntityFramework
  4. Get-Package EntityFramework -updates to see if there are newer versions available
  5. Update-Pacakge EntityFramework

NuGet Package Explorer – Including Create Package

I have always had work to do to copy my own assemblies into common locations. NuGet offers the possibility of hosting your own NuGet feeds, which may be local.  If I understand this correctly, this looks very interesting and might solve my issue and save me some time.

This requires the NuGet Package Explorer:

I found this would not install because I did not have .NET Framework 4.5 installed, as I am only on Visual Studio 2010. I installed 4.5 as my belief was that this would not break VS 2010. Creating the package then became easy with a few notes:

Use Tools > Analyze package to see if there are any issues.

It does like to have the target .Net Framework:

lib > net40 > myAssembly.dll

Creating your own package – Dependencies on your own packages

  1. Edit Metadata
  2. Edit dependencies
  3. Groups + Gave me [no target framework]
  4. Properties
  5. Package Source *** Put in here the location of your LocalNuGetFeed *** Reload
  6. Select your required package
  7. open


Creating your own online NuGet package feed



My favourite Nuget packages

  1. Entity Framework
  2. Data connection – for connection dialog box for my tool kit software




Programming against Sharepoint (Online) Client Side Object Model CSOM


Add References to:

  1. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll
  2. C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll

Problem 1

The referenced assembly “Microsoft.SharePoint.Client, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL” could not be resolved because it has a dependency on “System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a” which is not in the currently targeted framework “.NETFramework,Version=v4.0,Profile=Client”. Please remove references to assemblies not in the targeted framework or consider retargeting your project. SharepointWinFormsCSharp

Solution 1

Ensure that the project targets .Net Framework 4 and not Client Profile

Project > Properties > Application > Target Framework

Problem 2

The type or namespace name ‘SharepointOnlineCredentials’ does not exist in the namespace ‘Microsoft.SharePoint.Client’ (are you missing an assembly reference?)

Solution 2A – use this

First check that the spelling is precise including casing

Second, odd, but I copied the references to the bin folder and re-directed the reference to there and it started working. Odd thing was when I then pointed the reference back it continued to work.

Solution 2B – just creates a new problem

  1. Select Reference Microsoft.Sharepoint.Client
  2. Right-Click > Properties
  3. Embed Interop Types change from False to True
  4. Build

This returns new problem

  1. Cannot embed interop types from assembly ‘c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.Sharepoint.Client.dll” because it is missing either the ‘ImportedFromTypeLibAttribute’ attribute or the ‘PrimaryInteropAssemblyAsstribute’ attribute
  2. Cannot embed interop types from assembly ‘c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.Sharepoint.Client.dll” because it is missing the ‘GuidAttribute’ attribute

How to use CSOM

After the above each of the use cases in the following demonstrations then worked.

How to: Complete basic operations using SharePoint 2013 client library code

            using (var context = new ClientContext(""))
                var web = context.Web;
                var login = "xx@xx";
                var password = "xxxx";
                var securePassword = new System.Security.SecureString();
                foreach (char c in password)
                context.Credentials = new SharePointOnlineCredentials(login, securePassword);

The end

Where is “Add Web Reference” in Visual Studio?

With thanks to:


  1. Add service reference
  2. Advanced ( bottom LHS )
  3. Add Web Reference … ( bottom LHS )



SkyDrive Pro “Can’t connect to the specified SharePoint site…”


“Sorry we are having some temporary server issues.”
Office Outlook reporting that it is not activated

Solution 1

This may be a bit extreme and you may lose other settings, but this was the only thing I found that worked.
Internet Explorer > Tools > Internet Options > Advanced > Reset

Solution 2

My sub-site had unique permissions. When I removed the unique permissions, I was able to sync.

What did not help

Programs and Features > Office > Change > Repair

Windows Key – type credentials > Credential Manager > Remove a couple of the office credentials.

Interview Questions


Software and Database Developer Questions

  1. What is one of the first rules of data?


  1. How could a blog or wiki help you?



How to create a certificate – for Azure

Using MakeCert

After using makecert, it may say Succeeded, but you may not be able to find the certificate.
If you started from c:\Windows\system32 then It may be in c:\Windows\SysWOW64

To create your own self-signed management certificates which will be valid for Azure, open a Visual Studio command prompt as an administrator, and then run the following command:

makecert -sky exchange -r -n “CN=<CertificateName>” -pe -a sha1 -len 2048 -ss My “<CertificateName>.cer”

The CN may need to be

NOTE: If you get:
Error: CryptCertStrToNameW failed => 0x80092023 (-2146885597)

Then try manually deleting each ” and re-typing


Export from MMC

Not sure still learning, but current notes are

  1. Windows start type mmc.exe
  2. Probably current user for self-signed
  3. Select certificate
  4. Right-click All Tasks – Export
  5. Export with Private Key and Password
  6. Upload to the Service – Certificates in Azure



Configuring SSL for an application in Windows Azure