Wednesday, December 11, 2013

Visual Studio Online - Free TFS Server


I have always been a fan of TFS.  It keeps your team connected.  Linking your task management, builds and source control is very powerful.
Any of these features individually may not be that significant but together it can be very powerful.

Tracking what task is associated with a code check in and for what build makes it easy to figure out what is going on in your development project.



Now with visual studio online, I can leverage many of the TFS features for project for free.  And it hooks into my visual studio and looks just like I have my own TFS server.


Of course if you want to pay more, it can handle larger projects to.  For more users its only $10 per month. Much cheaper for most projects than hardware and a TFS license.

To start using TFS online 
1. go to visual studio online and register
     http://www.visualstudio.com/en-us/products/visual-studio-online-Overview-vs

2. open visual studio 2013
3. click on team from the top menu
4. connect to team foundation server
5. click select team projects
6. click on the servers button
7. click on add
8. enter in the URL of my visual studio online account I setup.

Now I have most of the power of TFS for free
1. Task management
2. Source control
3. TFS Build for continuous integration
4. And I did not have to spend a bunch of time configuring a server and software.

It appears id does not include the reporting features, but I don't use those as much anyways.

I have use TFS Build for CI pretty extensively in the past.  I am excited to get a project running and see how it works online.

Wednesday, November 27, 2013

Visual Studio 2012 comparison - F8 next difference keyboard shortcut

When comparing differences between 2 files in visual studio 2008 F8 will navigate to the next difference.

Windows Powershell Get-Content for monitoring log files similar to unix Tail

Windows Powershell Get-Content

Issue
For many developers testing or debugging often requires monitoring log files.
Closing and opening notepad gets tedious.
Soon, you have a bunch of notepads and you are note even sure what one is the current.

Power Shell to the rescue

1. Open windows powershell

2. enter this command
get-content logfile.log -Wait

3. You are now tailing your log file.



Tuesday, November 26, 2013

Grant Execute to all stored procs in a database

This script gives execute rights to all stored procs for the [USERNAME].  It uses a cursor, but it works well

DECLARE procs CURSOR FOR SELECT [name]
                         FROM sys.objects
                         WHERE type IN('p','AF','FN')
DECLARE @name AS VARCHAR(250)
DECLARE @stmt AS VARCHAR(1000)

OPEN procs

FETCH NEXT FROM procs INTO @name

WHILE @@FETCH_STATUS=0
BEGIN
    SET @stmt='GRANT EXECUTE ON '+@name+' TO [USERNAME]'
  
    EXEC(@stmt)
  
    PRINT @stmt
  
    FETCH NEXT FROM procs INTO @name
END

CLOSE procs

DEALLOCATE procs

Wednesday, November 20, 2013

Visual Studio 2012 TFS offline

Coding with TFS integration into your solution with a unreliable connection can be frustrating.

Frustration- Waiting for TFS timeout is a production Killer
  1. Start editing a file
  2. Visual studio tries to check out the file from TFS 
  3. You wait for the connection to timeout

Solution - Take Your Solution Offline
You can take your solution offline from source control.  Out of the box the only way for visual studio to go offline is to

  1. Close and re-open the solution.  
  2. hoping TFS is unavailable.  
To the rescue is a visual studio plugin that will let you go offline any time you wish.


Happy Coding!

Tuesday, October 15, 2013

Great blog post - maintaining software


This blog post was great.  It talked about maintaining existing software.

A favorite past time of most developers is to call your fellow geek over and have them check out some really smelly piece of code.  I am sure it even happens to my code from time to time, hopefully not to often.  



Friday, May 31, 2013

Remote Desktop to Hyper-V on Windows 8

So the virtual machine connection inside of hyper-v stinks.  Limited resolution choices and no copy/ past functionality.  None of the niceties of remote desktop.  As a developer a very difficult environment to work in.

So I spent some time trying to get it to work, and found this solution

https://stoknes.sharepoint.com/runesblog/Lists/Posts/Post.aspx?ID=12&mobile=0

I followed the instructions, did not change my default ip address.

Make sure you put the address in your remote desktop window as <your_virtual_machine's_name>.mshome.net


Wednesday, May 15, 2013

4 Steps to take a SQL SERVER Database out of Single User Mode

Recently my database got stuck in single user mode and I could not open it to change into multi-user.

Steps 1-4 will show you how it works.  Step 5 shows how to do it with one script

 I used the scripts below to fix this.
This is in SQL Server management studio with SQL Server R2

1. Find My Database id
    SELECT db_id('MyDB')


2. Find the session id that was using the single user mode, using the dbid returned from step 1 
    SELECT SPID,DBID,*
  FROM SYSPROCESSES
  WHERE DBID NOT IN(1,2,3,4) 

  AND SPID>50 
  AND SPID<>@@spid 
  AND dbid=[DBID]

3.Kill the session using the SPID from step 2
   KILL 999

4.put the database back into multi-user mode
   ALTER DATABASE MyDatabase
   SET MULTI_USER


Now you can get back into your database, 

       
Below is a script to do it all at once.
DECLARE @DBID AS INT
DECLARE @SPID AS INT
DECLARE @SQL AS NVARCHAR(MAX)

SELECT @SPID=SPID
FROM SYSPROCESSES
WHERE DBID NOT IN(1,2,3,4) AND SPID>50 AND SPID<>@@spid AND dbid=db_id('MyDatabase')

IF @SPID!=NULL
BEGIN
    SELECT 'Nothing to delete'
END
ELSE
BEGIN
    SET @SQL='KILL '+CONVERT(VARCHAR,@SPID)
   
    EXEC sp_executesql @SQL
END

ALTER DATABASE MyDatabase
SET MULTI_USER


To Format this TSQL I Used http://www.ubitsoft.com/products/t-sql-beautifier/ it worked great

Thursday, April 18, 2013

JQuery for a select all checkbox

So I have a asp.net repeater with a bunch of check boxes.  I want to have a select all/unselect all checckbox at the top of the repeater.

I used this little snippet of jquery to do it.

I got this great script from the bottom of a stack overflow post Here is a small revision on this, when doing this in asp.net with an ajax update panel you need to add the live. This way when the update panel refeshed the html, you can re-connect to your event.

Thursday, April 11, 2013

asp.net Update Panel and hiding elements

When working on a asp.net application that was using multiple update panels I was getting an error something like


Could not find UpdatePanel with ID 'xxx'. If it is being updated dynamically then it must be inside another UpdatePanel

I found the post below on stack overflow.


Basically my issue was that I was hiding the <asp:Panel> that contained the update panel.  This does not work at all.  You cannot do

<asp:panel visible="false" runat="server">
     <asp:UpdatePanel runat="server">
          <ContentTemplate>
                    <div>some stuff</div>
         </ContentTemplate>
    </asp:UpdatePanel>
</asp:panel>

Once I removed the visible="false" from the <asp:Panel> that my <asp:UpdatePanel> and everything worked like a charm.






Tuesday, March 12, 2013

WPF XAML App.config Transformations - Slow Cheeta

I was really tired of commenting and un-commenting out my app.config for my wpf application.  When  deploying I would forget to switch my database connection from dev to test or production.

I am now using Slow Cheeta to transform my app.config by build configuration.  Tying a build configuration to each one of my environments.  It is super easy and works great.

Tuesday, March 5, 2013

Visual Studio Keyboard Shortcut - Highlight Word Ctrl + Shift + Arrow

Sometimes when I am selecting text to cut "Ctrl+x" or paste "Ctrl+v" in visual studio I am selecting a bunch of text. This can take some time by holding the "Shift+right arrow" or "Shift+left arrow".

Recently I found a quicker way "Ctrl + Shift + Right Arrow" or "Ctrl + Shift + Left Arrow" will select a whole word.

Next time you are selecting a bunch of text try it out.  I tried this keyboard shortcut and it even works in Blogger.


Friday, March 1, 2013

Windows 8 - Day 1 Keyboard Shortcuts

So I got a new laptop with Windows 8.  So far its been Ok, but I really miss my start button.

To replace the start button I am using the keyboard shortcut key + Q searches applications.

So when I want to run SQL Server, or visual studio this works great.

I also found this other handy list of keyboard shortcuts

http://windows.microsoft.com/en-us/windows-8/new-keyboard-shortcuts#1TC=t1

Wednesday, February 27, 2013

SSRS - Setting up your development environment

I needed to start working on a few SSRS reports for a current project.  My new development is currently being done using VS2012.  I am still getting use to the interface, for normal web development I find 2012 to be an improvement over VS2010.  The only exception to this is I find the TFS integration to be more difficult to use in VS2012 than in VS2010.  So if I am editing work item templates or working with queries a lot I still  have 2010 running on my laptop most of the time.

I quickly learned that 2012 just like 2010 does not support BIDS.  If you want to build SSRS reports you must step back to VS2008.  So I cracked open VS2008, the oldest version I keep installed on my laptop, and started a new report. I went to check in my report to my TFS 2010 server and found that I do not even have a team menu.  I forgot that VS2008 does not come installed with TFS has a Team Viewer download that must be installed separately so I downloaded it from MSDN.  So I downloaded it and installed it from

Team Viewer Download
http://www.microsoft.com/en-us/download/details.aspx?id=16338

The next step was to connect to TFS.  I opened up the Team Menu and figured out my VS2008 did not have SP1 instaled so I downloaded that also.

VS2008 SP1
http://www.microsoft.com/en-us/download/details.aspx?id=20955

Finally because I was running TFS2010 I needed a compatibility pack downloaded from

TFS 2010 VS2008 Compatability Pack
http://www.microsoft.com/en-us/download/details.aspx?id=10834

I thought I was well on my way.  But I opened up the team menu and tried to connect to my TFS and it would not connect.  After some playing around I figured out you must type in the whole address to your TFS server to make it work.  The UI does not tell you this, but it will not work without doing the whole address

For Example http://tfsserver:8080/tfs

Happy Report Building with VS2008 and TFS2010





SQL Server Reporting Services - Where did my report window go

I was working on a SSRS report recently.  Not an every day occurrence for me.  But its always fun to strap into the way back machine, open Visual Studio 2008, and build a SRSS report or two.

So here I am in my report,  feeling at home in my mid 2000's development environment.  But still feeling lost unable to find the report data window.

I looked under windows and other windows from the menu and could not find it.  So I went to the keyboard and displayed the window using the expert friendly keyboard shortcut. ctrl + alt +d

Friday, February 15, 2013

Virus Protection

Just a quick note to my non-techie friends. If you are paying for anti-virus software save your money. There are free anti-virus programs that work just as well.  My favorite free anti-virus right now is Avast.

Avast Install

Tuesday, February 12, 2013

WPF Charting Toolkit - End Of Month

On a current project I am using the WPF charting toolkit. I needed to show the last day of the month on the X axis and not the first.

I am using a MVVM pattern implemented with MVVM Light.  Binding a KeyValuePair from my ViewModel to my View.

Using this post on code project I was able to do this quickly.

Thursday, February 7, 2013

T-SQL Table Size Script

I had a really large database that I was backup and restoring, and was wondering what was taking up all the space.

So I swiped this script.  I will give you a list of the tables in your database and how big they are.

Tuesday, February 5, 2013

WPF Ribbon WIndow - Binding Breaks on window resize

Ran into this really weird problem on a recent project.

In a WPF view I am using the ribbon toolkit  Something really weird  happened.  I had a combo box to a ribbon group.  I am using MVVM Light to implement the MVVM pattern inside my application.

After doing some research I found one entry on a MSDN forum here Binding Breaks that said this is a problem with the data context being lost when re-sizing the window.  This is a crazy scenario that should never happen.  In the post on MSDN they talk about over riding or changing code inside the ribbon toolkit.  I really did not want to do this.  Typically I avoid changing Microsoft or any third party code at nearly any cost.  It makes future support really hard.  And lets face it, I am not smarter that the team of Microsoft developers who build the library in the first place.

So I came up with a different solution.  If I was loosing data context why not just set data context explicitly on the combo box that was loosing data context.  And it worked

Here is a little sample of what I did.  In this sample I have a view (XAML File) and a view model and a static view model locator class to bind the views to the view models.  Following standard MVVM Light pattern.

Here is a small sample of my adding data context.


<pre  style="font-family:arial;font-size:12px;border:1px dashed #CCCCCC;width:99%;height:auto;overflow:auto;background:#f0f0f0;;background-image:URL(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoK_rOlCI0o8qqpoZvNwQ4r3ruEEUmcSnoNGvNK2_FdnjlRLIHVr8LjTb6W7VmWREvNm4nqfMcDkgi3GS0krWTPIi2-6AoL7vSnWO1fgf9K5WRLKBo0AxBpZ_REEbAssDJ3yrIb_4mnzeT/s320/codebg.gif);padding:0px;color:#000000;text-align:left;line-height:20px;"><code style="color:#000000;word-wrap:normal;"> DataContext="{Binding ViewModel, Source={StaticResource Locator}}"

So Normally I would not set my data context on the element, but just once for the entire page.  But adding the data context binding simply fixes this issue.  Much easier than modifying Microsoft code.

Wednesday, January 30, 2013

Visual Studio Keyboard Shortcut - Next Error

I always have to look this up when I am doing some major re factoring. 

When you have a bunch of errors and get tired of mousing to the error list in visual studio use this keyboard shortcut

F8 - go to the next error
shift + F8 - previous error

Tuesday, January 29, 2013

Visual Studio 2012 - Filter Solution Explorer

A really handy new feature I found in visual studio 2012 today was the filter solution by checked out or open files.

I always seem to have more files open than I can keep track of.  This really helps me reduce my time spent finding the correct open file.




Wednesday, January 23, 2013

Promo Windows 8 upgrade price ending 1/31/2013

If you are thinking of upgrading your PC to windows 8 do it before 1/31/2013 or the price will go from 14.99 - 39.99 to 199.99.

I will be doing this soon as 14.99 for my recent pc seems like a great price.  I know windows 8 has not got tons of great reviews, but I am going to give it a try and see how it goes.

Windows Pro 8 Upgrade

If you have purchased a PC recently and it came with the 14.99 offer here is the link to redeem it

Windows 8 14.99 Offer

Monday, January 21, 2013

asp.net Session State SQL Server Setup

On a  recent project I needed to add a SQLServer to manage my asp.net session state.  I could not find a single easy source on how to do this so here it is below.

Steps
1. Go to C:\Windows\Microsoft.NET\Framework64\v4.0.30319 on a command line
2. Paste and run - aspnet_regsql –ssremove –E -S .  this will remove the state server that is installed.  I have used this when I need to start over because my state server was not installed correctly.
3. Paste and run - aspnet_regsql.exe -S .\ -E -ssadd -sstype p
-S .\  This is the server name, in this case it uses the default server instance.  This works great for dev local setup, but you will need a real sql server name for deployments.
-sstype p don't put anything in the tempdb on the sql server, keep it all in the state database you are creating
-ssadd flag to create the tables, this exe can be used for membership provider pattern and other stuff, so make sure you only want to add the state server stuff.

4. In your web.config add
<sessionState mode="SQLServer" timeout="180" allowCustomSqlDatabase="true" sqlConnectionString="Data Source=.\;Initial Catalog=ASPState;Integrated Security=True"/>


Thursday, January 17, 2013

Windows Phone 8 Development - Day 0

I am an android phone user.  I have had an android phone for quite some time.  However being a Microsoft developer and knowing XAML I want to try out windows phone 8 development.

So I have been looking at buying a Windows Phone 8x and developing an application.  Before I plunge into a mobile phone platform switch I figured I should try to develop a simple app to see how I can leverage my .Net and XAML skills on the phone.

Googling (Being a good Microsoft guy I am sure I should use Bing instead) and Binged even sounds cool.
But after a search Google sent me to
Getting Started Developing for Windows Phone

Before reading any instructions on the screen I just went right to downloading the Windows 8 phone SDK.  This is when I found out I have to be running windows 8 to even develop a windows phone app.  This sure is a roadblock to trying it out. Not only do I need to buy a new phone, but I have to upgrade my OS on my development laptop.

I guess its off to installing windows 8, and visual studio 2012 so that I can do some windows development.

Note: If you want to get a Free Version of Visual Studio called Visual Studio Express.  This can be downloaded from

Visual Studio Express Download

Gmail POP Email Script

I use Gmail as my primary email.  I have other emails that I need to access so I use Gmail as my email client for these other email addresses. This way I can get them on my phone and everything is consolidated.  It works really well.  I can even send email as this other pop email account.

Unfortunately Gmail has an algorithm it uses to check your email box on pop email addresses.  And there is no setting to say how often to check your pop email address.  Because of this sometimes an email address sent to my POP email account will take hours to get into my inbox.  This is not a good situation.

To solve my problem I found this really cool script written by Daniel Slaughter that will check your pop email for you.  It works awesome. I have only tried in in Chrome, but it works for other browsers also.

http://www.danielslaughter.com/projects/gmail-pop3-checker-for-greasemonkey/


Wednesday, January 16, 2013

Coding at night

This article hit home for me.   9 to 1 am are my most productive times.

Coding at night

Tuesday, January 8, 2013