Sunday, August 23, 2015


Don't use ASP.NET MVC 4 Web API project template, it has all kinds of non-web service crap in it.

Use "ASP.NET Web Application" under Web, select "Empty" project and check the Web API checkbox. It will register a default route template and if you create a new controller you'll have a working service.

Saturday, August 8, 2015

Monday, January 19, 2015


Move to new folder

I had a VS solution that was in c:\TestGit\TestBootstrap\TestBootstrap
This folder had the root of the solution (however the .sln file was in c:\TestGit\TestBootstrap
I wanted to have the new folder structure be c:\TestGit\TestBootstrap\trunk\src
So I added to my local the trunk and src folders with a temp file in there so it would actually get into git.

do a 'git add *' (puts the folders into git staging)

do a 'git mv -n' first for a preview

git mv  -n TestBootstrap/TestBootstrap TestBootstrap/trunk/src
The above command worked from repo root of c:\TestGit.

Don't forget to delete the temp file.

Push to master
git push origin master

Summary only: 
git log --pretty=format:"%h - %an (%ae): %s" --shortstat

Configuring git for KDiff3
Add to .gitconfig:

    tool = kdiff3
    prompt = false
[difftool "kdiff3"]
    path = C:/Program Files/KDiff3/kdiff3.exe
    trustexitcode = true
    tool = kdiff3
[mergetool "kdiff3"]
    path = C:/Program Files/KDiff3/kdiff3.exe
    keepbackup = false
    trustexitcode = true

then run it using >git difftool .\folder\Web.config
yes, using quotes to deal with the spaces in program files in .gitconfig file screws it up. Don't use quotes.

Simple guide
Git in 600 words
Git docs

Getting set up in a new environment (git w/ PShell, PsGet, Posh-Git)

Thursday, January 8, 2015

Best Practices for Using Strings in the .NET Framework

Use string.Equals()
string s1 = "test";
string s2 = "test";
string s3 = "test1".Substring(0, 4);
object s4 = s3;
Debug.WriteLine("{0} {1} {2}", object.ReferenceEquals(s1, s2), s1 == s2, s1.Equals(s2));
Debug.WriteLine("{0} {1} {2}", object.ReferenceEquals(s1, s3), s1 == s3, s1.Equals(s3));
Debug.WriteLine("{0} {1} {2}", object.ReferenceEquals(s1, s4), s1 == s4, s1.Equals(s4));

True True True
False True True
False False True


Tuesday, December 2, 2014

localdb tips

SQL CLR is disabled by default, to enable:

using master

select * from sys.configurations where name = 'show advanced options'

sp_configure 'show advanced options', 1;
sp_configure 'clr enabled', 1;

select * from sys.configurations where name = 'show advanced options'

Create new localdb instance

sqllocaldb.exe create "Dev" 11.0  -s
This creates a localdb instance named Dev using the VStudio 2013 binaries and starts it.

Create  new database when getting "file already exists" errlr
-- open new query window against master db:

CREATE DATABASE CLFM ON (NAME = 'CLFM', FILENAME = 'C:\Users\vafsctonnet\UTest\CLFM.mdf')
LOG ON (NAME = 'CLFM_log', FILENAME = 'C:\Users\vafsctonnet\UTest\CLFM.ldf')

Efficient way to programmatically create localdb

Command line commands

from VStudio CMD:

get info on all db's on machine
SqlLocalDB.exe info
info on one db
SqlLocalDB.exe info UTest

SqlLocalDB.exe stop UTest
SqlLocalDB.exe start UTest

Make a copy of an existing database 

Make copies of the .ldf and .mdf files.
Then in server, right click Databases folder and select Attach. Select .mdf file. Done.